Do you really know how to use php count?

ringa_lee
Release: 2023-02-28 21:12:02
Original
1844 people have browsed it

The one we see most in daily projects should be count($array);

But if I need to count the number of elements in a multi-dimensional array. Do you want me to do statistics recursively? No, PHP is a smart language and will not let its developers do such stupid things.

Here we talk about the second parameter of count mode

int count ( mixed $array_or_countable [, int $mode = COUNT_NORMAL ] )
Copy after login

If it is not filled in, the default is 0; by default, the statistics of the sub-element array will not be performed.

If we need to do statistics, just change the second generation to 1

 php count你真的会用吗?

The above introduces php count. Do you really know how to use it? , including relevant content, 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!