PHP counts the number of array elements

WBOY
Release: 2016-08-08 09:21:44
Original
781 people have browsed it

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. You can get the elements in a regular scalar variable Number, if the array passed to this function is an empty array, or a variable that has not been set, the number of array elements returned is 0;
array_count_value(): counts each specific value in the array $array The number of occurrences;
For example:
$array=array(4,5,1,2,3,1,2,1);
$ac=array_count_value($array);
will create an array named $ac , the array includes:
                                                                                                                                                                                                                                                                                                                                                                                                                  3 2471338.html


The above introduces PHP to count the number of array elements, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!