What is the usage of the in_array function in PHP?
The in_array() function in PHP is used to check if a specified value exists in an array. Its syntax is:
bool in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )
Parameter Description:
- $needle: the value to be searched for
- The haystack is an array that contains the values to be searched.
- $strict: an optional parameter that, when set to true, makes the function also check types during search.
The function returns a boolean value, returning true if the specified value is found in the array, and false otherwise.