Voting

: four plus four?
(Example: nine)

The Note You're Voting On

alexandr at vladykin dot pp dot ru
19 years ago
My function returns the number of elements in array for multidimensional arrays subject to depth of array. (Almost COUNT_RECURSIVE, but you can point on which depth you want to plunge).

<?php
  function getArrCount ($arr, $depth=1) {
      if (!is_array($arr) || !$depth) return 0;
         
     $res=count($arr);
         
      foreach ($arr as $in_ar)
         $res+=getArrCount($in_ar, $depth-1);
      
      return $res;
  }
?>

<< Back to user notes page

To Top