number_format($n,$p) rounds $n to $p decimal places, adding commas between thousands
<? echo "Total charge is \$", number_format($total, 2), "\n"; ?>