Usage analysis of in_array function in php, phpin_array
This article analyzes the usage of in_array function in PHP with examples. Share it with everyone for your reference. The details are as follows:
PHP is a weakly typed language. Try to bring the third parameter when using the IN_ARRAY function. The code is as follows:
Copy code The code is as follows:
var_dump(in_array(0,array('s','sss'),true)); // return false
var_dump(in_array(0,array('s','sss'))); // return true
var_dump(in_array(0,array(1,2,3))); // return false
It can be seen from the above three functions that the first one: in_array(0,array('s','sss'),true) returns the value we want.
Use:
Copy code The code is as follows:
var_dump(in_array(0,array('s','sss')));
and:
Copy code The code is as follows:
var_dump(in_array(0,array(1,2,3)));
Returning true is obviously not the value we want, because PHP is mainly a weak type, so it is better for everyone to pay attention to it before.
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/912287.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/912287.htmlTechArticleAnalysis of the usage of the in_array function in php, phpin_array This article analyzes the usage of the in_array function in php. Share it with everyone for your reference. The details are as follows: PHP is a weakly typed language. When using IN_...