finding sum of the array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nevx009
Forum Newbie
Posts: 3
Joined: Sat Nov 14, 2009 1:38 pm

finding sum of the array

Post by nevx009 »

$prices=array("Brand New Computer"=>2000,"pencil"=>25,"Learning PHP"=>"60");

foreach($prices as $key=>$value) {

}

finding sum of the array e.g say we wanted to to see the price of the 2000 + 25+60 , can we have sum total of the $value ?what if we had a bigger list in the array
ant hlp appreciated

thks
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: finding sum of the array

Post by jackpf »

array_sum().

:)
Post Reply