in_array() String Int Comparisons¶
The default comparison style of in_array() is the relaxed one. Hence, the behavior of that comparison changed in PHP 8.0, so does in_array().
By default, comparing strings and integers may not work as before. This is the case when the string doesn’t convert obviously to an integer.
PHP code¶
<?php
var_dump(in_array(' 1a', [ 1]));
Before¶
bool(true)
After¶
bool(false)
PHP version change¶
This behavior changed in 8.0