TheJoey Posted October 15, 2009 Share Posted October 15, 2009 Hi just wondering how i would alter this for loop to display total cost of all items foreach($_SESSION['itemname'] as $k=>$v) { echo "Item Name : ".$v . ': Item Price : ' . $_SESSION['itemprice'][$k] . ': QTY : ' . $_SESSION['itemqty'][$k] ."<br></br>"; } Quote Link to comment Share on other sites More sharing options...
farkewie Posted October 15, 2009 Share Posted October 15, 2009 $sum = 0; foreach($_SESSION['itemname'] as $k=>$v) { $sum += $_SESSION['itemprice'][$k]; echo "Item Name : ".$v . ': Item Price : ' . $_SESSION['itemprice'][$k] . ': QTY : ' . $_SESSION['itemqty'][$k] ."<br></br>"; } echo $sum; Quote Link to comment Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 thanks man. Quote Link to comment 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.