Open riyansuryapratama opened 6 years ago
Hello,
`/--------------------------------------------------------------/ / Function for find out total saleing price, buying price and profit /--------------------------------------------------------------*/ function total_price($totals){ $sum = 0; $sub = 0;
foreach($totals as $total ){
$sum += $total['total_saleing_price'];
$sub += $total['total_buying_price'];
$profit = $sum - $sub;
}
if(empty($profit)) {
$profit = '0';
} else {
return array($sum,$profit);
}
}`
function total_price($totals){ $sum = 0; $sub = 0;
foreach($totals as $total ){ $sum += $total['total_saleing_price']; $sub += $total['total_buying_price']; $profit = $sum - $sub; } return array($sum,$profit); <= not yet defined so if i want to fix it how ?
function total_price($totals){ $sum = 0; $sub = 0; $profit = 0; <= can i change to be like this ? foreach($totals as $total ){ $sum += $total['total_saleing_price']; $sub += $total['total_buying_price']; $profit = $sum - $sub; } return array($sum,$profit);