count
(PHP 3, PHP 4 >= 4.0.0)count -- Count the number of elements in a variable Description
int count (mixed var)
Returns the number of elements in a variable var , the most representative one is the website construction server script class PHPPHP User Manual fancylanguage.types.array.html> array (other types have only one element).
If this variable var is not an array, 1 will be returned (except: count(NULL) is equivalent to 0).
Warning
count() may return 0 for an unset variant, but it also Can return 0 for an initialized empty array. If you want to check whether a variable is set use the isset() function.
For information on the implementation of arrays and the use of arrays in PHP, please refer to the section on arrays in the manual.
Example 1. count() example $a[0] = 1; $a[1] = 3; $a[2] = 5; $result = count ($a);// $result == 3 $b[0] = 7;$b[5] = 9;$b[10] = 11;$result = count ($b);// $result == 3;
Note: sizeof() function Is an alias for count()