note 34965 added to function.array-sum
| From: | mcrm at NOTNEEDIT dot freemal dot it | Date: | Wed, 13 Aug 2003 14:40:05 +0000 |
| Subject: | note 34965 added to function.array-sum | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54082@lists.php.net to get a copy of this message | ||
Hi people, if someone is searching a function that works also with multimension array, i suggest
this :
function cw_array_sum($a) {
if(!is_array($a)) return $a;
foreach($a as $key=>$value)
$totale += cw_array_count($value);
return $totale;
}
$a[0][E][PS][P][a1]=1;
$a[0][E][PS][P][a2]=2;
$a[0][E][PJ][P][a2]=2;
$a[1][E][PS][E][a3]=3;
echo cw_array_count($a[0]);
or
echo cw_array_count($a[0][E]);
Bye, Bye.
R.Martina
----
Manual Page -- http://www.php.net/manual/en/function.array-sum.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34965
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34965&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34965&report=yes