PHP multidimensional array search by value

前端 未结 23 3335
情歌与酒
情歌与酒 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:40

    Try this

    $value) {
            $current_key=$key;
            if($needle===$value OR (is_array($value) && 
                recursive_array_search($needle,$value) !== false)) {
                 return $current_key;
            }
        }
        return false;
     }
     ?>
    

提交回复
热议问题