1
2<?php
3$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
4
5$key = array_search('green', $array); // $key = 2;
6$key = array_search('red', $array); // $key = 1;
7?>
8
9
1array_search ( mixed $needle , array $haystack , bool $strict = false ) : int|string|false
2
3<?php
4$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
5
6$key = array_search('green', $array); // $key = 2;
7$key = array_search('red', $array); // $key = 1;
8?>
1$userdb=Array
2(
3 (0) => Array
4 (
5 (uid) => '100',
6 (name) => 'Sandra Shush',
7 (url) => 'urlof100'
8 ),
9
10 (1) => Array
11 (
12 (uid) => '5465',
13 (name) => 'Stefanie Mcmohn',
14 (pic_square) => 'urlof100'
15 ),
16
17 (2) => Array
18 (
19 (uid) => '40489',
20 (name) => 'Michael',
21 (pic_square) => 'urlof40489'
22 )
23);
24
25simply u can use this
26
27$key = array_search(40489, array_column($userdb, 'uid'));
1$userdb = array(
2 array(
3 'uid' => '100',
4 'name' => 'Sandra Shush',
5 'pic_square' => 'urlof100'
6 ),
7 array(
8 'uid' => '5465',
9 'name' => 'Stefanie Mcmohn',
10 'pic_square' => 'urlof100'
11 ),
12 array(
13 'uid' => '40489',
14 'name' => 'Michael',
15 'pic_square' => 'urlof40489'
16 )
17);
18