如何找到数组的大小
16lz
2021-01-22
1) how to find the size of an array
2) how to execute a block of code where the size of array is greater then zero?
1)如何找到数组的大小2)如何执行数组大小大于0的代码块?
if($result > 0){
/////////here is some code body which i want to execture/////////
}eles{
///////some other code////////
}
4 个解决方案
#1
11
you can use count() or sizeof() php functions like
可以使用count()或sizeof() php函数
if(sizeof($result) > 0){
echo "array size is greater then zero";
}else{
echo "array size is zero";
}
or you can use
或者您也可以使用
if(count($result) > 0){
echo "array size is greater then zero";
}else{
echo "array size is zero";
}
I hope it will help you
我希望它能对你有所帮助
更多相关文章
- PHP:将simpleXML对象转换为二维数组
- 从JSON字符串/数组中提取第一个图像
- PHP根据数组的值分组
- 找出数组中大于或等于N的数
- PHP用空格分割文本为数组的方法
- 如何使用ChromePhp Logger记录数组
- 解决Apache2+PHP上传文件大小限制的问题技术集锦
- 在数组中计数,其中值为0
- 如何获取关联数组的当前元素数?