Home >Backend Development >PHP Tutorial >Scared to think about it? About the third parameter of in_array
Use in_array ()
Determine whether there is a certain value in the array. If the third parameter is omitted, sometimes the result may be meaningless...
For example, the following Code snippet:
<?php $arr = [true, false]; $f = in_array('Hello', $arr); if($f) echo 'in array'; else echo 'not found'; //结果输出 in array
Changed to in_array('Hello', $arr, true)
This problem can be solved
This problem does not exist in JS, for example, use The indexOf () function can be rewritten like this
I don’t know if this question will make you fall into silence→_→
Related recommendations: "PHP video tutorial》
The above is the detailed content of Scared to think about it? About the third parameter of in_array. For more information, please follow other related articles on the PHP Chinese website!