in_array() 函數在數組中搜索給定的值。
語法
in_array(value,array,type)
參數
value
必需。規定要在數組搜索的值。
array
必需。規定要搜索的數組。
type
可選。如果設置該參數為 true,則檢查搜索的數據與數組的值的類型是否相同。
如:
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
if (in_array("Glenn",$people))
{
echo "Match found";
}
else
{
echo "Match not found";
}
?>