How to write in the array only permitted the keys?

Good afternoon.
there is an array of allowed fields and the array with the data you need to find a convergence:
$allowed = ['id', 'type', 'url'];
$data = ['id' => 1, 'type' => 2, 'url' => 'toster.ru', 'other' => 'that seems excessive.'];

How can I leave only the allowed fields?

Now I only have 2 solutions:
1 - array_intersect_key (But it only works with associative arrays have allowed to do not beautiful)
2 - Bust cycle is allowed and keys to form a new pulling values from the second array (But I'm sure it's some kind of crutch, and it is possible to solve the standard functions of language)

array_intersect_ukey - works on random brand compares if the keys did not fit unfortunately.

Please tell me how to do?

PS MB Yii is already implemented ? - at the docks ArrayHelper I found this
March 19th 20 at 09:06
1 answer
March 19th 20 at 09:08
Solution
$data = array_intersect_key($data, array_flip($allowed));
@justina.Kloc , thanks, didn't know about this lipace) - Vaughn.Stokes commented on March 19th 20 at 09:11

Find more questions by tags PHP