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:
$userdb = array(
array(
'uid' => '100',
'name' => 'Sandra Shush',
'pic_square' => 'urlof100'
),
array(
'uid' => '5465',
'name' => 'Stefanie Mcmohn',
'pic_square' => 'urlof100'
),
array(
'uid' => '40489',
'name' => 'Michael',
'pic_square' => 'urlof40489'
)
);
The function call search_by_uid(100)
(uid of first user) should return 0
.
The function call search_by_uid(40489)
should return 2
.
I tried making loops, but I want a faster executing code.
you can use this function ; https://github.com/serhatozles/ArrayAdvancedSearch
I want to check tha in the following array
$arr
is there 'abc' exists in sub arrays or notThen i can use this
I think This is the Most simple way to define
With help of above code one can find any(partially matched) data from any column in 2D array so user id can be found as required in question.