php中判断一个值是否存在于数组中,可以使用in_array函数。
语法:in_array($value, $array)
参数:
返回值:
示例:
$array = array('apple', 'banana', 'orange');
if (in_array('apple', $array)) {
echo 'apple exists in the array';
} else {
echo 'apple does not exist in the array';
}
输出:
apple exists in the array
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站