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
PHP HTTP request ignores parameters
Before I start asking questions, I should mention that I am re-learning PHP after a long t...
From 2024-04-05 10:54:48
0
1
3536
Set relation "OR" for meta_query ORtax_query
I'm trying to use WP_Query to create a query containing a meta_query element and a tax_que...
From 2024-04-04 20:01:43
0
1
1346
Search posts by tags
I need to display posts by tags. My solution works for a single tag like this: Route::get(...
From 2024-04-03 22:38:54
0
1
430
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|