Open wilidga opened 6 years ago
function total_price($totals){ $sum = 0; $sub = 0; $profit = 0; /*add variable for the profit result*/ foreach($totals as $total ){ $sum += $total['total_saleing_price']; $sub += $total['total_buying_price']; $profit = $sum - $sub; } return array($sum,$profit); }
just define variable profit with 0
https://github.com/bitsandbots/inventory
function total_price($totals){ $sum = 0; $sub = 0; $profit = 0; /*add variable for the profit result*/ foreach($totals as $total ){ $sum += $total['total_saleing_price']; $sub += $total['total_buying_price']; $profit = $sum - $sub; } return array($sum,$profit); }