0

I an looking to search an array based on a nested arrays value. My Array looks like this.

$arr = array(100 => array('fname' => 'John', 
                          'lname' => 'Smith', 
                          'phone' => '18005551212'), 
            555 => array('fname' => 'Michael', 
                         'lname' => 'Gold', 
                         'phone' => '18005550000')
        )

I know I can use $arr[100] to get the values there. How would I go about searching for the value where say their phone number is 18005551212 and then find the array key based on that? Is the only option to have a for each and loop through the entire array every time?

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Dovid Bender
  • 139
  • 9

0 Answers0