在PHP中,可以使用count()函数来计算数组元素的个数。下面是一个例子:
```php
$fruits = array("apple", "banana", "orange", "grape");
$numberOfFruits = count($fruits);
echo "There are " . $numberOfFruits . " fruits in the array.";
```
在这个例子中,count()函数会返回数组$fruits中元素的个数,然后将这个个数打印出来。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:python怎么计算数组元素个数