(PHP 4 >= 4.0.0)
in_array -- Return TRUE if a value exists in an arraySearches haystack for needle and returns TRUE if it is found in the array, FALSE otherwise.
If the third parameter strict is set to TRUE then the in_array() will also check the types of the needle in the haystack.
Note: If needle is a string, the comparison is done in a case-sensitive manner.
Note: In PHP versions before 4.2.0 needle was not allowed to be an array.
Example 1. in_array() example
The second condition fails because in_array() is case-sensitive, so the program above will display:
|
Example 2. in_array() with strict example
This will display:
|
Example 3. in_array() with an array as needle
|
See also array_search().