Home  >  Article  >  Backend Development  >  Do you really know how to use php count?

Do you really know how to use php count?

ringa_lee
ringa_leeOriginal
2018-05-14 14:35:231905browse

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

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.


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