A basic tutorial for getting started with PHP. Friends in need can refer to it on how to use the in_array function.
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.
Note: If the value parameter is a string and the type parameter is set to true, the search is case-sensitive.
Example #1 in_array() Example
The code is as follows
|
Copy code
|
||||||||
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
Related labels:
source:php.cn
Previous article:Usage of php list function_PHP tutorial
Next article:Code of Conduct for Programmers_PHP Tutorial
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
Latest Articles by Author
Latest Issues
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|