2014-07-18 33 views
0

我想分塊大數。例如。在一組三個塊中分塊大數字php

//between each three decimals a dot should be placed 
33 thousand like this  33.000 
33 milion like this 33.000.000 

我該如何在PHP中做到這一點?

+4

見[number_format](http://php.net/manual/en/function.number-format.php) –

回答

1

使用number_format()

number_format(
    $number, 
    0,   //amount of decimal points 
    ',',  //decimal seperator 
    '.'  //thousands seperator 
); 
2

下面是一個例子:

number_format("33000",0,"","."); 
number_format("33000000",0,"",".");