FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » summing an array of arrays
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
summing an array of arrays [message #173501] Sat, 16 April 2011 00:06 Go to previous message
jr is currently offline  jr
Messages: 4
Registered: January 2011
Karma:
Junior Member
$aryTemp=("A"=>Array(1,5,3),
"B"=>Array(15,20,52))

sum_subarrays_by_key($aryTemp, $aryTemp[$key]


function sum_subarrays_by_key($aryTemp, $key)
sum=0;
foreach($aryTemp as $sub_array){

$sum += $sub_array[$key];}
}
return $sum:
}

What I want to know how to do is change the above script to make it
add a 3rd array of arrays?
c=> Array(C1=> Array(17,4,8), C2=>Array(1,4,10))

thanks, Jan
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Figure out path to php.ini
Next Topic: will code/solve problems for money
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 09:52:13 GMT 2024

Total time taken to generate the page: 0.04812 seconds