Are there any php function that do this:
$source = array('id1'=>'name', 'id2'=>'name2', 'id3'=>'name3');
$keys = array('id1', 'id3');
$projection = project($source, $keys);
I want:
$projection = array('name', 'name3');
I searched the standard array functions for a long time and I could not find anything.
Not as such. You could get closer to what you’re trying to do using:
Or:
However, this will not work if a given item appears twice in the key array.
If you have access to PHP 5.3, you can use a closure: