I have a PHP array like this (sans syntax):
array
(
['one'] => array (
['wantedkey'] => 5
['otherkey1'] => 6
['otherkey2'] => 7
)
['two'] => => array (
['otherkey1'] => 5
['otherkey2'] => 6
['wantedkey'] => 7
)
['three'] => => array (
['otherkey1'] => 5
['wantedkey'] => 6
['otherkey2'] => 7
)
)
What's the best way to print the values for only the elements with a key of 'wantedkey' , if I'm using array_walk_recursive for example?
New requirement from comment under answer:
Apologies, I forgot to mention, what if I want to check if the keys are the same in a multidimensional way:
$item['wantedkey1']['wantedkey2']How do I make sure both keys are present?