php - how to get one specific entry in multi dimensional array -
php - how to get one specific entry in multi dimensional array -
this print_r of array
array ( [0] => array ( [displayorder] => 3 [menuname] => accounting module [menuurl] => [menuflag] => 1 [menuid] => 3 ) [1] => array ( [displayorder] => 4 [menuname] => profile [menuurl] => myprofile.php [menuflag] => 0 [menuid] => 4 ) [2] => array ( [displayorder] => 6 [menuname] => hr module [menuurl] => [menuflag] => 1 [menuid] => 2 ) [3] => array ( [displayorder] => 9 [menuname] => administrator [menuurl] => [menuflag] => 1 [menuid] => 1 ) )
i want create status when have menuid
input menuname
of array of menuid
found solution:
$myarray[0]['menuname'];
here
but gets menuname
of first array how can create dynamic?
create function passing multi array , menu id parameter it, homecoming desired value multi-array, like:
function getmenunamebyid($yourarr, $menuid) { foreach($yourarr $val) { if( $val["menuid"] == $menuid ) { homecoming $val["menuname"]; } } } //use $menuname = getmenunamebyid($your_multi_arr, $menu_id);
php arrays
Comments
Post a Comment