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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -