PHP count function second parameter

 

We all used count function to get the number of items from an array.

But did you used count with 2 parameters?

What will be the output of the following code?

If you aspect to be 4 you are wrong. You were true if you print count($a).

Why?

Because second argument from count means COUNT_RECURSIVE, so the correct answer is 8.

Default behavior:

Reference: http://php.net/manual/en/function.count.php