PHP - Check if Array exists in Multidimensional Array with an Exact Match of Pair -


i need check if exact pair of 2 values exists in multidimensional array together.

i have array this:

array ( [code] => 200 [response] => success [0] => array     (         [email] => example123@sample.com         [status] => approved: printed & cleared     )  [1] => array     (         [email] => xxexample123@sample.com         [status] => pending     )  [2] => array     (         [email] => example1345@sample.com         [status] => approved     )  [3] => array     (         [email] => example1235@sample.com         [status] => approved: printed & cleared     ) ) 

then have array looks this:

array     (         [email] => xxexample123@sample.com         [status] => pending     ) 

i need check if exact pair exists in multidimensional array. not status , email appear seperate each other.

you can use array_search() in same manner if need key, @ simplest (assuming $array1 has keys , values being search , in same order):

$array2 = array('email'  => 'example123@sample.com',                 'status' => 'pending');  if(in_array($array2, $array1)) {     //yes } else {     //no } 

see demo showing found , not found.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -