$letters = array(array("a","b")); echo (count($letters,1)); | Sololearn: Learn to code for FREE!


$letters = array(array("a","b")); echo (count($letters,1));

What is the output and how?


10/20/2021 2:39:01 AM

Rohit Ahuja

2 Answers

New Answer


Quoting from https://www.php.net/manual/en/function.count.php "mode If the optional mode parameter is set to COUNT_RECURSIVE (or 1), count() will recursively count the array. This is particularly useful for counting all the elements of a multidimensional array." For the array in your example, you will get 3 from count() because the inner array plus its 2 elements are counted in.


Thnku so much