Home  >  Article  >  Backend Development  >  PHP4 User Manual: Function-count_PHP Tutorial

PHP4 User Manual: Function-count_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:22:20913browse


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()


See also: sizeof(), isset(), and is_array().

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532352.htmlTechArticlecount (PHP 3, PHP 4 >= 4.0.0)count -- Description of the number of elements in the calculation variable int count (mixed var) returns the number of var elements in a variable. The most representative one is the website construction server script...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn