Jump to content

How to format 12345 into 123,45 in PHP ?


alpercelk

Recommended Posts

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

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.