views:

131

answers:

3

I currently do:

 $totalBill = number_format($totalBill, 2); 
 $totalBill = '$'.$totalBill;

This does not handle cases though where the total is say 10 cents. It returns "$0.1" which I do not want. Does anyone have a better way?

+3  A: 
$totalBill = sprintf('$%.2f',$totalBill);
Adam Kiss
+3  A: 

You probably want money_format() instead

Michael Mrozek
+1  A: 

Use PHP's money_format function.

Annath