Count (PHP3, PHP44.0.0) count -- calculate the number of elements in the variable description intcount (mixedvar) returns the number of var elements of a variable, the most representative is the array (other types only have one element ). If the var variable is not an array, 1 (except: count (NULL) SyntaxHigh is returned.
Count
(PHP 3, PHP 4> = 4.0.0) count -- calculate the number of elements in a variable.
Int count (mixed var)
Returns the number of var elements. the most representative is an array of fancylanguage.types.array.html> in the script class of the website construction server ).
If the var variable is not an array, 1 (except: count (NULL) is equivalent to 0) is returned ).
Warning
Count () may return 0 for an unspecified variable, but it can also return 0 for an initialized empty array. If you want to check whether a variable is set, use the isset () function.
For array implementation and use of PHP in arrays, see the array section in the manual.
Example 1. count () example $ a [0] = 1; $ a [1] = 3; $ a [2] = 5; $ result = count ($ ); // $ result = 3 $ B [0] = 7; $ B [5] = 9; $ B [10] = 11; $ result = count ($ B ); // $ result = 3;
Note: The sizeof () function is an alias of count ().
See sizeof (), isset (), and is_array ().