Var_dump (In_array (0, Array (' s '));
The result of this sentence is bool (true).
Because In_array will compare 0 and ' s ', 0 is the number type, ' s ' is a string type, and according to the instructions in the "Comparison Operators" chapter of PHP Tutorial manual, number and string
When comparing, the string type is first converted to number, and then the comparison operation. The result of ' s ' conversion to number is 0, and the result of 0 = = 0 is true, so the result of In_array (0, Array (' s ', ' SS ')) is also true
If the third parameter of In_array is set to True, the comparison will determine whether the value and type are equal. Returns true if all are equal, otherwise returns false.
About PHP In_array syntax
BOOL in_array2881064151 (mixed $needle, array $haystack [, BOOL $strict]) return value is straight or false
<?php
$a = Array (' 1.10 ', 12.4, 1.13);
if (In_array (' 12.4 ', $a, true)) {
echo "' 12.4 ' found with strict checkn";
}
if (In_array (1.13, $a, true)) {
echo "1.13 found with strict checkn";
}
?>
How to set the third parameter of In_array to true strict