PHP 8.5.0 Alpha 1 available for testing

Voting

: min(five, zero)?
(Example: nine)

The Note You're Voting On

danny at dannymendel dot com
18 years ago
I actually find the following function more useful when it comes to multidimension arrays when you do not want all levels of the array tree.

// $limit is set to the number of recursions
<?php
function count_recursive ($array, $limit) {
$count = 0;
foreach (
$array as $id => $_array) {
if (
is_array ($_array) && $limit > 0) {
$count += count_recursive ($_array, $limit - 1);
} else {
$count += 1;
}
}
return
$count;
}
?>

<< Back to user notes page

To Top