Heim  >  Artikel  >  Backend-Entwicklung  >  php统计数组元素个数,php数组个数_PHP教程

php统计数组元素个数,php数组个数_PHP教程

WBOY
WBOYOriginal
2016-07-13 09:47:57975Durchsuche

php统计数组元素个数,php数组个数

count():对数组中的元素个数进行统计;

sizeof():和count()具有同样的用途,这两个函数都可以返回数组元素个数.可以得到一个常规标量变量中的元素个数,如果传递给这个函数的数组是一个空数组,或者是一个没有经过设定的变量,返回的数组元素个数就是0;

array_count_value():统计每个特定的值在数组$array中出现过的次数;

如:

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

   $ac=array_count_value($array);

将创建一个名为$ac数组,该数组包括:

                      

                       关键字       值

                         4          1

                         5          1

                         1          3

                         2          2

                         3          1


文章源地址:http://www.cnblogs.com/taletao/archive/2012/04/26/2471338.html

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1025225.htmlTechArticlephp统计数组元素个数,php数组个数 count():对数组中的元素个数进行统计; sizeof():和count()具有同样的用途,这两个函数都可以返回数组元素个数...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn