I have two arrays that look like this:
$fields = array('id', 'name', 'city', 'birthday', 'money');
$values = array('id' => 10,
'name' => 'Jonnas',
'anotherField' => 'test',
'field2' => 'aaa',
'city' => 'Marau',
'field3' => 'bbb',
'birthday' => '0000-00-00',
'money' => 10.95
);
Is there a built-in PHP function that retrieves an array filled only with the keys specified in the $fieldsarray (id, name, city, birthday, money)?
Expected Return:
$values2 = array(
'id' => 10,
'name' => 'Jonnas',
'city' => 'Marau',
'birthday' => '0000-00-00',
'money' => 10.95
);
PS: I am only looking for a built-in function.
source
share