This site is mobile accessible. Press the "Tap Here" button to use a different font-size.
Smartphone icons created by Freepik - Flaticon
The count() function returns the number of elements in an array.
count(array, mode)
Parameter | Description |
---|---|
array | Required. Specifies the array to sort |
mode | Optional. Specifies the mode. Possible values:
|
Return Value: | Returns the number of elements in the array |
PHP Version: | 4+ |
PHP Changelog: | The mode parameter was added in PHP 4.2 |
Return the number of elements in an array:
<?php $cars=array("Volvo","BMW","Toyota"); echo count($cars); ?>
Count the array recursively:
<?php $cars=array ( "Volvo"=>array ( "XC60", "XC90" ), "BMW"=>array ( "X3", "X5" ), "Toyota"=>array ( "Highlander" ) ); echo "Normal count: " . count($cars)."<br>"; echo "Recursive count: " . count($cars,1); ?>
Eventually the navigation links, above, will be replaced by these (previous) and (next) buttons below.
Animated PHP icons used in the buttons provided by ICONS8.COM. Smartphone icons created by Freepik - Flaticon