Jump to content

Formatting Decimals


Perad

Recommended Posts

I have this line.

 

$form .= "<td>£$price[$i] ex VAT
<br />£".$price[$i]*1.175." inc VAT</td>";

 

this returns

 

£41.95 ex VAT

£49.29125 inc VAT

 

I would like the inc VAT price to become £49.29

 

I have tried

$form .= "<td>£$price[$i] ex VAT<br />£".printf("%.2f", ($price[$i]*1.175))." inc VAT</td>";

 

But this doesn't work, does anyone have any other suggestions?

Link to comment
https://forums.phpfreaks.com/topic/66485-formatting-decimals/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.