in_array

PHP 4, PHP 5, PHP 7, PHP 8
in_array - Checks if a value exists in an array

in_array( mixed$needle, array$haystack, [bool$strict = false] ): bool

Searches for needle in haystack using loose comparison unless strict is set.

Parameters

needle

The searched value.

Note:

If needle is a string, the comparison is done in a case-sensitive manner.

haystack

The array.

strict

If the third parameter strict is set to true then the in_array function will also check the types of the needle in the haystack.

Return Values

Returns true if needle is found in the array, false otherwise.

Related Functions

Example of in_array

Show all examples for in_array

PHP Version:


Function in_array:

Arrays Functions

Most used PHP functions