Perad Posted August 24, 2007 Share Posted August 24, 2007 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 More sharing options...
AndyB Posted August 24, 2007 Share Posted August 24, 2007 %01.2f not %.2f See example 2415 at http://ca.php.net/manual/en/function.sprintf.php Link to comment https://forums.phpfreaks.com/topic/66485-formatting-decimals/#findComment-332880 Share on other sites More sharing options...
vijayfreaks Posted August 24, 2007 Share Posted August 24, 2007 Hi.. use "number_format" function for this.. string number_format ( float number [, int decimals [, string dec_point, string thousands_sep]] ) Regards, Vijay Link to comment https://forums.phpfreaks.com/topic/66485-formatting-decimals/#findComment-332881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.