PHP multidimensional array search by value

0 votes

I want to search for the uid in an array and get the key of the array.

Example

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'
    )
);

Can someone help me with a faster-executing code for this?

May 30 in PHP by Kichu
• 19,040 points
11 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to delete element by value in array (not key) using php?

Hello @kartik, Using array_search() and unset, try the following: if (($key = ...READ MORE

answered Sep 16, 2020 in PHP by Niroj
• 82,700 points
185 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,700 points
1,387 views
0 votes
1 answer

How to access array returned by a function in php?

Hello @kartik, Since PHP 5.4 it's possible to ...READ MORE

answered Nov 10, 2020 in PHP by anonymous
• 82,700 points
350 views
0 votes
0 answers

How can I check if an array contains a specific value in php?

I have a PHP variable of the ...READ MORE

Jun 4 in PHP by Kichu
• 19,040 points
7 views
0 votes
0 answers

PHP Unset Array value effect on other indexes

I want to know how unset affects ...READ MORE

5 days ago in PHP by narikkadan
• 10,840 points
5 views
0 votes
0 answers

Difference between call by value and call by reference in php and also $$ means?

What is the difference between call by ...READ MORE

4 days ago in PHP by narikkadan
• 10,840 points
28 views
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,240 points
3,919 views
0 votes
0 answers

How to sum all column values in multi-dimensional array?

How can I add all the columnar ...READ MORE

Jun 19 in PHP by narikkadan
• 10,840 points
5 views
0 votes
1 answer

How to store input value into array then localstorage?

Hello @ abhittac, You have create the array everytime the ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,700 points
4,511 views
0 votes
1 answer

Convert a PHP object to an associative array

Start with simply typecasting the line:- $array = ...READ MORE

answered Feb 23 in PHP by Aditya
• 7,280 points
111 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP