I was wondering if there is a native PHP function for returning an array made up of of a certain set of given key=>value elements from another array, given a list of require keys. Here's what I mean:
// Nice information
$source_array = array('a' => 'hello', 'b' => 'goodbye', 'c' => 'good day', 'd' => 'sunshine');
// Required element keys
$array_two = array('a','b');
$array_three = array('a','d');
// Get that stuff from $source_array...
// $array_two_result = ???
// $array_three_result = ???
// Show it
print_r($array_two_result);
print_r($array_three_result);
Outputs:
Array(
[a] => 'hello'
[b] => 'goodbye'
)
Array(
[a] => 'hello'
[d] => 'sunshine'
)
I've been looking through the documentation but can't find anything as of yet, but it doesn't seem to me like a particularly deviant thing to want to do, hence the question.