要获取一个数组的元素个数,可以使用PHP内置的count()函数。例如:
$fruits = array("apple", "banana", "orange");
$count = count($fruits);
echo "数组元素个数:" . $count;
输出结果为:
数组元素个数:3
如果要获取一个常量数组的元素个数,可以使用count()函数或者sizeof()函数。例如:
define("FRUITS", array("apple", "banana", "orange"));
$count = count(FRUITS);
echo "常量数组元素个数:" . $count;
输出结果为:
常量数组元素个数:3
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站