PHP How To Find the Keys of A Value In Multidimensional Array -
i have been working on problem, have had no result current functions of php.
i have multidimensional array, like:
array ( [3] => array ( [16] => 0 [17] => 1 [18] => 2 ) [4] => array ( [22] => 3 [23] => 4 ) [5] => array ( [1] => 5 ) )
if first keys of array static, have been easy fix, keys dynamical data. (3, 4, 5 etc...). have function finds keys of value.
myfunction($myarray, 3) // 3 = value.
if there value "3", want function give me keys of it. (4, 22). array on top.
thanks in advance.
suppose want array of keys index of array contains searched value (3), , index of 3 value in array, should works:
$matched = []; foreach($object $extindex => $array){ foreach($array $intindex => $value){ if($value == 3){ $matched[] = [$extindex, $intindex]; } } } var_dump($matched);
edit: $object object described in question.
Comments
Post a Comment