时间:2021-07-01 10:21:17 帮助过:18人阅读
<?php $people = array("Peter", "Joe", "Glenn", "Cleveland"); if (in_array("Glenn",$people)) { echo "Match found"; } else { echo "Match not found"; } ?>
输出:
Match found例子 2
<?php $people = array("Peter", "Joe", "Glenn", "Cleveland", 23); if (in_array("23",$people, TRUE)) { echo "Match found<br />"; } else { echo "Match not found<br />"; }if (in_array("Glenn",$people, TRUE)) { echo "Match found<br />"; } else { echo "Match not found<br />"; }if (in_array(23,$people, TRUE)) { echo "Match found<br />"; } else { echo "Match not found<br />"; } ?>
输出:
Match not found
Match found
Match found
更多php数组函数序列之in_array() - 查找数组中是否存在指定值相关文章请关注PHP中文网!