HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP Array Reference : Return the number of elements in an array
The sizeof() function returns the number of elements in an array.
The sizeof() function is an alias of the count() function.
Parameter | Description |
---|---|
array | Required. Specifies the array |
mode | Optional. Specifies the mode. Possible values:
|
Return Value: | Returns the number of elements in the array |
---|---|
PHP Version: | 4+ |
Count the array recursively:
<?php
$cars=array
(
"Volvo"=>array
(
"XC60",
"XC90"
),
"BMW"=>array
(
"X3",
"X5"
),
"Toyota"=>array
(
"Highlander"
)
);
echo "Normal count: " . sizeof($cars)."<br>";
echo "Recursive count: " . sizeof($cars,1);
?>
❮ PHP Array Reference