easyedy Posted December 21, 2007 Share Posted December 21, 2007 Hi I have a 3 diminsional array and I need to get a sum of certain quantity but I just can seem to be able to get it. ANy suggestions? for ($qty = 0; $qty < sizeof($result[$FA][$SA]); $qty++) { echo array_sum($result[$FA][$SA][$qty]['Quantity']);} If i echo $result[$FA][$SA][$qty]['Quantity'] it spits out all the correct $qty's for each row but I can't figure out to add them all together to get a total sum. thanks Quote Link to comment https://forums.phpfreaks.com/topic/82757-adding-vars-to-get-a-sum-in-for-statement/ Share on other sites More sharing options...
PHP_PhREEEk Posted December 22, 2007 Share Posted December 22, 2007 With $result populated, can you please insert the following code and post the results here? <?php echo "<pre>"; print_r($result); die(); If the printout is too long, just post a good-sized portion of it. Thanks. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/82757-adding-vars-to-get-a-sum-in-for-statement/#findComment-421054 Share on other sites More sharing options...
Barand Posted December 22, 2007 Share Posted December 22, 2007 Better still, use var_export() in place of print_r() That way we can process your array without endless editing to make it usable code. Quote Link to comment https://forums.phpfreaks.com/topic/82757-adding-vars-to-get-a-sum-in-for-statement/#findComment-421101 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.