Definition
PHP in_array() function checks if value exits in an array.
Syntax
The basic syntax of the in_array() function is given with
in_array(search, array, strict);
The in_array()
function accepts the following parameters.
Parameter | Description |
---|---|
search | Required. Specifies the searched value. If it is a string, the comparison is done in a case-sensitive manner. |
array | Required. Specifies the array to be searched. |
strict | Optional. Determines if strict comparison (=== ) should be used during the value search. Possible values are true and false . Default value is false . |
Example1 : Below example Search for the value "House" in an array and output some text
Output : Match found!
Example2 :following example will also match the type of searched value using strict parameter.
Output : No match found!