is_array

(PHP 4, PHP 5, PHP 7, PHP 8)

is_array检测变量是否是数组

说明

is_array(mixed $value): bool

检测变量是否是数组。

参数

value

待检测的变量。

返回值

如果 valuearray,则返回 true,否则返回 false

范例

示例 #1 检测变量是否为数组

<?php
$yes
= array('this', 'is', 'an array');
echo
is_array($yes) ? 'Array' : 'not an Array';
echo
"\n";
$no = 'this is a string';
echo
is_array($no) ? 'Array' : 'not an Array';
?>

以上例程会输出:

Array
not an Array

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top