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? Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.