Home > Article > Backend Development > Do you really know how to use php count?
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
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.