Page 1 of 1

adding drops the zero.

Posted: Tue Dec 10, 2002 10:16 am
by penguinboy
i'm trying to add dollar values

like


$cost = "12.00";

$othercost = "12.60";

$total = $cost + $othercost;


echo "$ $total";


well i want it to echo "$ 24.60";

but instead its echoing "$ 24.6";

so how do i get around this problem, I've tried using "", '', () but noting seems to work.

thanks for any help

-pb

Posted: Tue Dec 10, 2002 10:51 am
by volka
you might format the output via printf/sprintf
http://www.php.net/manual/en/function.sprintf.php