note 102611 added to function.array-sum
| From: | sicoanimal at hotmail dot com | Date: | Thu, 24 Feb 2011 12:35:30 +0000 |
| Subject: | note 102611 added to function.array-sum | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177281@lists.php.net to get a copy of this message | ||
A very simple function to recursively sum up the values of an array
function array_recursive_sum($array) {
$sum = 0;
foreach ($array as $value) {
if (is_array($value)) {
$sum += $this->array_recursive_sum($value);
} else {
$sum += $value;
}
}
return $sum;
}
----
Server IP: 87.124.126.105
Probable Submitter: 87.84.128.98 (proxied: 87.84.128.98)
----
Manual Page -- http://www.php.net/manual/en/function.array-sum.php
Edit -- https://master.php.net/note/edit/102611
Del: integrated -- https://master.php.net/note/delete/102611/integrated
Del: useless -- https://master.php.net/note/delete/102611/useless
Del: bad code -- https://master.php.net/note/delete/102611/bad+code
Del: spam -- https://master.php.net/note/delete/102611/spam
Del: non-english -- https://master.php.net/note/delete/102611/non-english
Del: in docs -- https://master.php.net/note/delete/102611/in+docs
Del: other reasons-- https://master.php.net/note/delete/102611
Reject -- https://master.php.net/note/reject/102611
Search -- https://master.php.net/manage/user-notes.php