Usage Analysis of in_array function in php, phpin_array
This article analyzes the in_array function usage in php. 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:
Copy codeThe 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:Copy codeThe Code is as follows: var_dump (in_array (0, array ('s', 'ss'); and:Copy codeThe 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.