Possible Duplicate:
PHP Built-in Method to Get Array Values Given a List of Keys
Does PHP has built-in function for this purpuse?
I have two arrays, first associative with some data. For example:
$data = array(
'name' => 'John',
'last_name' => 'Smith',
'address' => 'NY, ...',
'phone' => '1234567'
);
And another array with keys:
$keys = array(
'name',
'last_name'
);
After aplying this function I get only values from first array, which have keys from second array.
$result = function($data, $keys);
print_r($result);
// array(
// 'name' => 'Jonh',
// 'last_name' => 'Smith'
// )