PHP sizeof() Function
Complete PHP Array Reference Manual
Example
Return the number of elements in an array:
Run Example »
Definition and Usage
The sizeof() function returns the number of elements in an array.
The sizeof() function is an alias of count(). count() function.
Syntax
sizeof(
array,mode
);
| Parameters | Description |
|---|---|
| array | Required. Specifies the array to count. |
| mode | Optional. Specifies the mode of the function. Possible values:
|
Technical Details
| Return Value: | Returns the number of elements in the array. |
|---|---|
| PHP Version: | 4+ |
More examples
Example 1
Count the elements of an array recursively:
array ( "XC60", "XC90" ), "BMW"=>array ( "X3", "X5" ), "Toyota"=>array ( "Highlander" ) ); echo "Normal count: " . sizeof($cars).""; echo "Recursive count: " . sizeof($cars,1); ?>
Run Example »
Complete PHP Array Reference Manual