I have a $total
with a value of 1400
which I'm trying to echo as 1,400.00
however sprintf
and number_format
refuse to cooperate with each other. How do I properly format the $total
to echo
as 1,400.00
?
<?php
$total = 1400;
echo sprintf('%0.2f',$total);
//'1400.00'
echo number_format($total);
//'1,400'
echo sprintf('%0.2f',number_format($total_grand));
//'1.00'
echo number_format(sprintf('%0.2f',$total));
//'1,400'
?>