alpercelk Posted November 10, 2009 Share Posted November 10, 2009 Hi guys, I have some numbers coming from MySQL in this format 12345 and I would like to represent this number in 123,45 or 123.45 format. How can I do this? Link to comment https://forums.phpfreaks.com/topic/180988-how-to-format-12345-into-12345-in-php/ Share on other sites More sharing options...
Psycho Posted November 10, 2009 Share Posted November 10, 2009 number_format(): http://php.net/manual/en/function.number-format.php $number = 123456; echo number_format( ($number/100), 2); //Output: 1,234.56 echo number_format( ($number/100), 2, ',', ' '); //Output: 1 234,56 I showed the examples with a six digit number to show what happens with the thousands separator Link to comment https://forums.phpfreaks.com/topic/180988-how-to-format-12345-into-12345-in-php/#findComment-954903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.