|
[Edit] Sum up all the values in the array associatively
Example// make an associative array $array = array(1,array(1),array(1,array(1))); echo array_sum_assoc($array); // outputs 4, array_sum would output 1 function array_sum_assoc($array){
if(!is_array($array) || sizeof($array) === 0){
return false;
}
$count = 0;
foreach($array as $key=>$value){
if(is_array($value)){
$count += array_sum_assoc($value);
}else{
$count += $value;
}
}
return $count;
}
|
This Page is Under Construction! - If You Want To Help Please Send your CV - Advanced Web Core (BETA)
© Advanced Web Core. All rights reserved

