Count the array recursively:


SUBMITTED BY: henry1874w

DATE: June 26, 2017, 5:11 p.m.

FORMAT: Text only

SIZE: 265 Bytes

HITS: 293

  1. <?php
  2. $cars=array
  3. (
  4. "Volvo"=>array
  5. (
  6. "XC60",
  7. "XC90"
  8. ),
  9. "BMW"=>array
  10. (
  11. "X3",
  12. "X5"
  13. ),
  14. "Toyota"=>array
  15. (
  16. "Highlander"
  17. )
  18. );
  19. echo "Normal count: " . count($cars)."<br>";
  20. echo "Recursive count: " . count($cars,1);
  21. ?>

comments powered by Disqus