Skip to content
Chung Leong edited this page Jan 10, 2022 · 3 revisions

in_array - Checks if a value exists in an array

bool in_array ( mixed $needle, array $haystack )

in_array() searches haystack for needle.

Parameters:

needle - The searched value. If haystack is a one-dimensional array, then needle should be a scalar. If haystack is a multi-dimensional array, then needle of should be an array of the same size as the subarrays of haystack. The size of needle must be known at compile-time. It cannot be an expandable array.

haystack - The array to perform the search on.

Return Value:

true if needle is found in the array and false otherwise.

Version

1.0 and above.

Clone this wiki locally