温馨提示×

PHP中如何用sizeof()获取数组长度

PHP
小亿
82
2024-04-02 14:53:00
栏目: 编程语言

在PHP中,可以使用sizeof()函数来获取数组的长度。例如:

$fruits = array("apple", "banana", "orange", "kiwi");
$length = sizeof($fruits);
echo "The length of the array is: " . $length;

上面的代码将输出:The length of the array is: 4。这表示数组$fruits中有4个元素。

0