PHP multidimension array key search -
so, have multidimensional array (for example):
array[1][22]['name'] array[1][33]['name'] array[2][44]['name'] array[3][55]['name']
i know last array key(it's id) (for example - [44]), how can find value of [name] known key?
in guess need array_search, key , in multidimensional array...
here's simple way php >= 5.5.0. assumes there 1 key 44
in array:
echo array_column($array, 44)[0]['name']; // or echo current(array_column($array, 44))['name'];
earlier versions:
foreach($array $k => $v) { if(isset($v[44])) echo $v[44]['name']; }
Comments
Post a Comment