I have the following code:
$data = array(); // prep array $data['aardvark'] = true; print_r($data); // output array echo "\n"; var_dump(in_array('zebra', $data));
The output is as follows:
Array ( [aardvark] => 1 ) bool(true)
Despite the fact that zebra clearly not in the array. This seems to be related to the PHP free type system. (bool) 'zebra' is true , and there is true in the array, so in_array returns true?
I think I can see the logic, but it is corrupted. Is this a PHP bug?
Greetings.
source share