Forum Moderators: coopster
$incoming = '478.25';
$outgoing = '129.36';
$net = ($incoming - $outgoing);
echo $net;
$file = 'balance.txt';
$vals = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$count = count($vals);
$tot = 0;
for($i = 0; $i < $count; $i++) {
$vals[$i] = trim($vals[$i]);
$tot += $vals[$i];
}
echo $tot;
$bal_file = 'balance.txt';
$inc_file = 'income.txt';
$out_file = 'expenses.txt';
$bal = end(file($bal_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
$inc = end(file($inc_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
$out = end(file($out_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
$bal += ($inc - $out);
echo $bal;