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>"; } Link to comment https://forums.phpfreaks.com/topic/177769-solved-alter-for-loop/ 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; Link to comment https://forums.phpfreaks.com/topic/177769-solved-alter-for-loop/#findComment-937363 Share on other sites More sharing options...
TheJoey Posted October 15, 2009 Author Share Posted October 15, 2009 thanks man. Link to comment https://forums.phpfreaks.com/topic/177769-solved-alter-for-loop/#findComment-937369 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.