If we want to search any value in array then we can use in_array() function. This function will return true or false according to search value.
If search value found then in_array() function will return true.
Syntax
in_array(search,array,type);
search: Required, Specifies the search for in given array
array: Required, given array
type: Optional, The search will case-sensitive if type is true and type is string.
$animal= array("Cow", "Dog", "Cat", "Monkey"); if (in_array("Cat", $animal)) { echo "Match found"; } else { echo "Match not found"; }
Output:
Match found