I have this array
$languages = array (
'de' =>
array (
'FIRSTNAME' => 'Vorname',
'SURNAME' => 'Nachname'
),
'en' =>
array (
'FIRSTNAME' => 'Firstname',
'SURNAME' => 'Surname'
)
);
and I am trying to get the full index (full key) of $languages by using the value of SURNAME for example.
Example: Looking for 'Firstname' should return $languages['en']['FIRSTNAME']
I tried array_search combined with array_column but in fact I don't know the "column" to look for
array_search($value, array_column($array_to_search_in, 'column'));
I also found a solution with array_walk_recursive but only with key comparison, not by value.
array_walk_recursive($languages, function($v, $k, $u) use (&$values){
if($k == $value) {
$values[] = $v;
}
}, $values );
Any help is as always highly appreciated!! Thanks!
array_walk_recursive()code, try swapping the test to be$v == $valueand$values[] = $k(you will also need to add$valueto youruseclause.Array ( [0] => FIRSTNAME ). I need also the first "key" which is "en"