-
-
$people = array("Peter", "Joe", "Glenn", "Cleveland");
if (in_array("Glenn",$people))
- {
- echo "Match found";
- }
- else
- {
- echo "Match not found";
- }
- ?>
-
复制代码
输出:
Match found
例2:
-
-
- $people = array("Peter", "Joe", "Glenn", "Cleveland", 23);
if (in_array("23",$people, TRUE))
- {
- echo "Match found
";
- }
- else
- {
- echo "Match not found
";
- }if (in_array("Glenn",$people, TRUE))
- {
- echo "Match found
";
- }
- else
- {
- echo "Match not found
";
- }if (in_array(23,$people, TRUE))
- {
- echo "Match found
";
- }
- else
- {
- echo "Match not found
";
- }
- ?>
-
复制代码
输出:
Match not found
Match found
Match found
|