PHP in_array() Function
Last Updated : 17 Mar 2025
The in_array( ) function is an inbuilt function of PHP. It is used to search an array for a specific value. If the third parameter strict is set to true, the in_array( ) function will also check the types of the $values.
Syntax
Parameter
| Parameter | Description | Is compulsory |
|---|---|---|
| value | Specifies the value to be searched in the array. | compulsory |
| array | Specifies an array. | compulsory |
| strict | If this parameter is set, the in_array( ) function searches for the search-string and specific type in the array. | Optional |
Returns
The function returns true if the value is found in the array or false otherwise.
Example 1
Output:
found
Example 2
Output:
Got jobGot innovation
Example 3
Output:
great player
Example 4
Output:
found not found
Next TopicPhp-array-intersect-assoc-function