count

int count(mixed variable) 

Returns the number of elements in a variable.

Returns:

Number of elements in the given variable

Description:

This function returns the number of values contained in the variable given by variable . For scalar variables, this is always 1, unless the variable is unset or contains only NULL, in which case it’s 0. For objects, methods are not counted; nor are attributes having no value (attributes with a value of NULL are counted, however). For arrays, all elements having values—even NULL—are counted. Unset elements are not counted. Elements of subarrays are not counted separately, and each subarray counts as one value.

Note:

sizeof() is an alias for count(); they’re identical in every way except the name.

Version: ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.