Home >Backend Development >PHP Tutorial >PHP determines whether an element appears in an array
In PHP, you can use the in_array() function to directly determine whether an element is in an array. If the element exists in the array, the in_array() function returns true, otherwise it returns false. This article mainly shares with you how to use PHP to determine whether an element appears in an array. I hope it can help you.
in_array(search,array,type)
Description | |
---|---|
search | Required. Specifies the value to search for in the array.|
array | Required. Specifies the array to search.|
type | Optional. If this parameter is set to true, it is checked whether the type of the searched data and the value of the array are the same.
The above is the detailed content of PHP determines whether an element appears in an array. For more information, please follow other related articles on the PHP Chinese website!