Home  >  Article  >  Backend Development  >  PHP counts the number of array elements, the number of PHP arrays_PHP tutorial

PHP counts the number of array elements, the number of PHP arrays_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:47:571001browse

php counts the number of array elements, the number of php arrays

count(): counts the number of elements in the array;

sizeof(): It has the same purpose as count(). Both functions can return the number of array elements. You can get the number of elements in a regular scalar variable. If the array passed to this function is an empty array, or an array that has not been passed For the set variable, the number of array elements returned is 0;

array_count_value(): counts the number of times each specific value appears in the array $array;

such as:

$array=array(4,5,1,2,3,1,2,1);

$ac=array_count_value($array);

will create a Named $ac array, the array includes:

                          4 1

5 5 1

1 3

2 2

3 1


Article source address: http://www .cnblogs.com/taletao/archive/2012/04/26/2471338. html





http://www.bkjia.com/PHPjc/1025225.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/1025225.htmlTechArticlephp counts the number of array elements, php array count count(): counts the number of elements in the array ; sizeof(): has the same purpose as count(). Both functions can return the number of array elements...
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