PHP multidimensional array search by value

前端 未结 23 3245
情歌与酒
情歌与酒 2020-11-21 04:45

I have an array where I want to search the uid and get the key of the array.

Examples

Assume we have the following 2-dimensional array:

<
23条回答
  •  抹茶落季
    2020-11-21 05:29

    you can use this function ; https://github.com/serhatozles/ArrayAdvancedSearch

    ='2'";
    
    $Array = array(
    'a' => array('d' => '2'),
    array('a' => 'Example World','b' => '2'),
    array('c' => '3'), array('d' => '4'),
    );
    
    $Result = ArraySearch($Array,$query,1);
    
    echo '
    ';
    print_r($Result);
    echo '
    '; // Output: // Array // ( // [0] => Array // ( // [a] => Example World // [b] => 2 // ) // // )

提交回复
热议问题