This article mainly introduces the in_array function usage in php, and analyzes the in_array function usage and related precautions in PHP in the form of examples, which has some reference value, for more information about how to use the in_array function in php, see the example in this article. Share it with you for your reference. The details are as follows:
PHP is a weak language. when using the IN_ARRAY function, try to include the third parameter. the code is as follows:
The code is as follows:
Var_dump (in_array (0, array ('s', 'SS'), true); // return false
Var_dump (in_array (0, array ('s', 'SS'); // return true
Var_dump (in_array (0, array (1, 2, 3); // return false
From the above three functions, we can see that when the first one is in_array (0, array ('s', 'SS'), true), the returned value is the value we want.
Usage:
The code is as follows:
Var_dump (in_array (0, array ('s', 'SS ')));
And:
The code is as follows:
Var_dump (in_array (0, array (1, 2, 3 )));
The returned ture is obviously not the value we need, because PHP is the weak type, so you should pay attention to it before.
I hope this article will help you with php programming.