Been a while. Have a simple one – what does this print?
$arr[null] = "Null string"; $arr[false] = "False string"; $arr[0] = "Zero string"; print_r($arr);
It’s…
Array ( [] => Null string [0] => Zero string )
Surprise!
It gets better:
$arr[null] = "Null string"; $arr[false] = "False string"; $arr[0] = "Zero string"; $arr[''] = "Empty string string";
gives
Array ( [] => Empty string string [0] => Zero string )
Hat tip to Will for this one.
So, why? Why does changing the keys change which of them print?
1. FALSE is sometimes zero.
2. null is sometimes ”.
Never quite exactly, but close enough for arrays.