* @version 1.0.0 * @link http://aidanlister.com/repos/v/function.array_count_recursive.php * @param $array array Array * @param $depth int Depth of recursion [Default: 0 (Infinite)] * @param $thisdepth int Must be 1 [Default: 1] */ function array_count_recursive($array, $depth = 0, $thisdepth = 1) { // End of recursion if (!is_array($array)) { return 1; } // Init $total = 0; // Count if ($depth === 0 || $thisdepth < $depth) { foreach ($array as $value) { $total += array_count_recursive($value, $depth, $thisdepth + 1); } } else { $total += count($array); } // Return return $total; } ?>