Home  >  Article  >  Backend Development  >  Is there a function to determine whether a number is in a known array?_PHP Tutorial

Is there a function to determine whether a number is in a known array?_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:53:37731browse

bool in_array (mixed needle, array haystack [, bool strict])
Search for needle in haystack and return TRUE if found, otherwise return FALSE.
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: Before 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/632396.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...
Statement:
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