Counting elements in arrays
The count( ) function returns the number of elements in the array var:
integer count(mixed var)
The following example prints 7 as expected:
$days = array("Mon", "Tue", "Wed", "Thu",
"Fri", "Sat", "Sun");
echo count($days); // 7
The count( ) function works on any variable type and returns 0 when either an empty array or a variable that isn't set is examined. If there is any doubt, isset( ) and is_array( ) should be used to check the variable being considered.