coklat12 Posted November 9, 2007 Share Posted November 9, 2007 hello. i have two arrays : $quantity = array(1,2,3); $price = array(15.45,12.3,23); how do i make those two arrays for a multiply calculation like this : $total = $quantity * $price; i want the total of the calculations in a new array please help me thanks. Quote Link to comment Share on other sites More sharing options...
coklat12 Posted November 9, 2007 Author Share Posted November 9, 2007 anybody pls help me. how to solve this Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 9, 2007 Share Posted November 9, 2007 Try: <?php $quantity = array(1,2,3); $price = array(15.45,12.3,23); $totals = array(); for($x=0;$x<count($quantity);$x++){ $totals[] = $quantity[$x]*$price[$x]; } echo '<pre>'; print_r($totals); echo '</pre>'; ?> Quote Link to comment Share on other sites More sharing options...
coklat12 Posted November 9, 2007 Author Share Posted November 9, 2007 it works! thanks! 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.