l!m!t Posted June 21, 2008 Share Posted June 21, 2008 Hi I am trying to add a loop of values into a total. (like the mYSQL SUM function). Any idea on how I do this without mySQL? I tried array_sum, but cant get it to work. Any easy examples someone could provide would be great. foreach ($file->get_contents() as $item) { $qty_total = $item['qty']; } $actual_cost_array= array($qty_total); $result=array_sum($actual_cost_array); // <- Should total, but doesn't.. If there is an easier way please advise. Thank you. Link to comment https://forums.phpfreaks.com/topic/111283-solved-sum-values-without-mysql/ Share on other sites More sharing options...
trq Posted June 21, 2008 Share Posted June 21, 2008 [code=php:0] foreach ($file->get_contents() as $item) { $qty_total += $item['qty']; } Link to comment https://forums.phpfreaks.com/topic/111283-solved-sum-values-without-mysql/#findComment-571217 Share on other sites More sharing options...
l!m!t Posted June 21, 2008 Author Share Posted June 21, 2008 Thanks Thorpe! It worked and I learned something! Thanks again. Link to comment https://forums.phpfreaks.com/topic/111283-solved-sum-values-without-mysql/#findComment-571223 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.