I have a source array that looks like this:
$data = array(
'foo' => array(
'bar' => 'foo_bar',
'baz' => 'foo_baz'
),
'fizz' => array(
'bar' => 'fizz_bar',
'baz' => 'fizz_baz'
)
);
I would like to create another array by selecting a key: bar
or baz
, which will return all of the root keys with the values of the specified key?
some_function($data, 'bar') == array(
'foo' => 'foo_bar',
'fizz' => 'fizz_bar'
);
Is there a built-in php function(s) to generate the following results without doing my own loops?