In php, the in_array() function is used to search whether a specified value exists in the array, the syntax is "in_array(search,array,type)"; if the search parameter is a string, and the type parameter is set to TRUE, the search is case-sensitive.
Recommended: "PHP Video Tutorial"
in_array() function searches whether the specified value exists in the array.
Syntax
in_array(search,array,type)
Parameters:
Description
Return value: Returns TRUE if the value is found in the array, otherwise returns FALSE.
Example:<?php $people = array("Bill", "Steve", "Mark", "David"); if (in_array("23", $people, TRUE)) { echo "匹配已找到<br>"; } else { echo "匹配未找到<br>"; } if (in_array("Mark",$people, TRUE)) { echo "匹配已找到<br>"; } else { echo "匹配未找到<br>"; } if (in_array(23,$people, TRUE)) { echo "匹配已找到<br>"; } else { echo "匹配未找到<br>"; } ?>
匹配未找到 匹配已找到 匹配未找到
The above is the detailed content of How to use in_array in php? (Usage introduction). For more information, please follow other related articles on the PHP Chinese website!