Home > Backend Development > PHP Tutorial > Usage analysis of in_array function in php, phpin_array_PHP tutorial

Usage analysis of in_array function in php, phpin_array_PHP tutorial

WBOY
Release: 2016-07-13 10:13:55
Original
921 people have browsed it

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.

www.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_...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template