PHP multidimensional array search by value

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

    Looks array_filter will be suitable solution for this...

    $userdb=Array
    (
        (0) => Array
            (
                (uid) => '100',
                (name) => 'Sandra Shush',
                (url) => 'urlof100'
            ),
    
        (1) => Array
            (
                (uid) => '5465',
                (name) => 'Stefanie Mcmohn',
                (pic_square) => 'urlof100'
            ),
    
        (2) => Array
            (
                (uid) => '40489',
                (name) => 'Michael',
                (pic_square) => 'urlof40489'
            )
    );
    

    PHP Code

提交回复
热议问题