PHP in_array() Function
PHP in_array() Function
The in_array() function in PHP checks if the value exists in the specified array or not.
Syntax
in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] )
Parameter
needle(required)- This parameter represents the searched value.
haystack(required)- This parameter represents the input array.
strict(optional)- This parameter searches for the search-string; if it is set to the Boolean value TRUE, then it will also the types of the array.
Return
This function returns a Boolean value TRUE if the parameter “needle” is found in the array else it returns FALSE.
Example 1
Output
Hello Reema! Welcome to TutorialandExample.
Example 2
Output
CASE 1: Without Strict Check '112.4' found without strict check CASE 2: Strict Check '112.4' is not found with strict check
Example 3
Output
Array ( [0] => Reema [1] => Varun [2] => Ginni [3] => Sukla [4] => 23 ) 23 is not found in the array Reema is found in the array