Home > Backend Development > PHP Tutorial > Function to determine whether a number is in a known array_PHP Tutorial

Function to determine whether a number is in a known array_PHP Tutorial

WBOY
Release: 2016-07-20 10:59:33
Original
859 people have browsed it

​ bool in_array (mixed needle, array haystack [, bool strict])
Searches the haystack for needle and returns TRUE if found, FALSE otherwise.
If the value of the third parameter strict is TRUE, the in_array() function will also check whether the type of needle is the same as that in haystack.
Note: If needle is a string, the comparison is case-sensitive.
Note: Prior to PHP version 4.2.0, needle was not allowed to be an array.
Example 1. in_array() example
$os = array ("Mac", "NT", "Irix", "Linux");
if (in_array ("Irix", $os)) {
print "Got Irix";
}
if (in_array ("mac", $os)) {
print "Got mac";
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445598.htmlTechArticlebool in_array (mixed needle, array haystack [, bool strict]) Search needle in haystack and return if found TRUE, otherwise returns FALSE. If the value of the third parameter strict is...
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