0

My program's logic is complex, but I am facing problem in a little part, where I need to search for a key,value pair in a multidimensional array. For that, I am using a combination of array_search() and array_column() functions.

To demonstrate the problem, I have written the following little SSCCE.

$arrayOne = array ( '$oid' => '5e140f97e603f88ee52008ab' );

$arrayTwo = array ( 
  0 => array ( '$oid' => '5e140f97e603f88ee52008ab')
);

if ( array_search($arrayOne, $arrayTwo) ) {
    echo "True";
} else {
    echo "False";
}

The output is always False.

Now, since the key,value pair $oid,5e140f97e603f88ee52008ab IS there in $arrayTwo, so why am I getting False in output?

JBel
  • 329
  • 1
  • 5
  • 19

0 Answers0