php中如何判断数组为空

在php中判断数组是否为空的方法
1.使用empty()函数判断
$arr = [];
if (empty($arr)) {
//为空
} else {
//不为空
}
如返回结果为true,则表示数组为空。
2.使用count()函数判断
$arr = [];
if (count($arr) < 1) {
//为空
} else {
//不为空
}
如返回结果小于1,则表示数组为空。

在php中判断数组是否为空的方法
1.使用empty()函数判断
$arr = [];
if (empty($arr)) {
//为空
} else {
//不为空
}
如返回结果为true,则表示数组为空。
2.使用count()函数判断
$arr = [];
if (count($arr) < 1) {
//为空
} else {
//不为空
}
如返回结果小于1,则表示数组为空。
扫码添加客服微信