php in_array
时间: 2023-11-20 20:07:36 浏览: 40
The in_array() function in PHP is used to check whether a value exists in an array or not. It returns true if the value is found in the array, otherwise, it returns false. The syntax of the in_array() function is:
in_array(value, array, strict);
Where:
- value: The value to search for in the array.
- array: The array in which to search for the value.
- strict (optional): A boolean parameter that specifies whether to perform a strict comparison (true) or not (false). If this parameter is not specified, it defaults to false.
Example:
$input = array("apple", "banana", "orange");
if (in_array("apple", $input)) {
echo "Found apple in the array";
} else {
echo "Did not find apple in the array";
}
Output:
Found apple in the array
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)