PHP判断一个数组是否为空

版权声明:咔咔 来自https://blog.csdn.net/fangkang7 https://blog.csdn.net/fangkang7/article/details/83477113

empty($array_test) //如果数组$array_test为空那么这个函数返回true
if($array_test) //如果数组为空.那么if的条件判断为false
count($array_test) //计算数组元素个数.为0就是空
sizeof($array_test) //count() 的别名 用法和返回一样
 
//实际上还有一些方式可以判断数组是否为空.常用的就是这些
补充一下
如果数组没有被定义
还可以使用
isset($array_test)//判断数组是否被定义

猜你喜欢

转载自blog.csdn.net/fangkang7/article/details/83477113