I have this array:
$ar = [ 'key1'=>'John', 'key2'=>0, 'key3'=>'Mary' ];
and if I write:
$idx = array_search ('Mary',$ar); echo $idx;
I get:
key2
I searched through the network and this is not an isolation problem. It appears that when the associative array contains the value 0, array_search fails if the strict parameter is not set.
There are also several error warnings, all rejected with motivation: "array_search () makes free comparison by default."
Ok, I solve my little problem using a strict parameter ...
But my question is: is there a decent, good reason why in the free comparison 'Mary'==0 or 'two'==0 , or is this just another php madness?
source share