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 have searched over the net and this is not isolate problem. It seems that when an associative array contains a 0 value, array_search fails if strict parameter is not set.
There are also more than one bug warnings, all rejected with motivation: “array_search() does a loose comparison by default”.
Ok, I resolve my little problem using strict parameter...
But my question is: there is a decent, valid reason why in loose comparison 'Mary'==0
or 'two'==0
or it is only another php madness?