PHP multidimensional array search by value

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

    Here is one liner for the same,

    $pic_square = $userdb[array_search($uid,array_column($userdb, 'uid'))]['pic_square'];
    

提交回复
热议问题