PHP Array sizeof() Function
Last Updated : 17 Mar 2025
The sizeof( ) function is an alias of count( ) function. The sizeof( ) function returns the number of elements in an array. This function was introduced in PHP 4.0.
Syntax
Parameter
| Parameter | Description | Is compulsory |
|---|---|---|
| array | Specifies the array to use. | compulsory |
| mode | Specifies the mode. Possible values: 0 - Default. Does not count all elements of multidimensional arrays 1 - Counts the array recursively (counts all the elements of multidimensional arrays) | Optional |
Returns
The sizeof( ) function returns the number of elements in the array.
Example 1
Output:
8
Example 2
Output:
4
Example 3
Output:
5
Example 4
Output:
5
Next TopicPhp-array-sort-function