The Count:count () function calculates the number of cells in an array or the number of attributes in an object, returns the number of its elements for an array, returns 1 for other values,
If the argument is a variable and the variable is not defined, 0 is returned, and if mode is set to Count_recursive (or 1), the number of elements of the array in the multidimensional array is recursively computed.
sizeof: Definition and usage, the sizeof () function calculates the number of cells in an array or the number of attributes in an object.
Syntax: sizeof (Array,mode)
| Parameters |
Describe |
| Array |
Required, specifies the array or object to count. |
| Mode |
Optional, specify the mode of the function, the possible values:
0-Default. Do not detect arrays in multidimensional arrays, arrays.
1-multidimensional array detection. |
Note: The parameter mode is added in PHP 4.2.
Tip Count sizeof
Note: When the variable is not set, or the variable contains an empty array, the function returns 0, and the isset () variable can be used to test whether the variable is set.
PHP detection array length function sizeof vs. Count usage