This is a simple number format changing in php. In here, i’ll change number format like 1,000 into 1.000.
I’ll give you the source, here it is:
<?php
$val = ’12345678′;
$baru = number_format($val);
$hasil = ”;
for($i=0;$i<strlen($baru);$i++)
{
$data = array(
$i => $baru[$i]
);
if($data[$i] == ‘,’)
{
unset($data[$i]);
$data[$i] = ‘.’;
}
$hasil = $hasil.$data[$i];
}
echo $hasil
?>
The output will be 12.345.678
number_format() function will make standard number like 1,000.
That’s all. It is so simple, is it?


try to use:
number_format(123456789, 0 , ‘,’, ‘.’);
it more easy then your way.
thanks habibillah for your code. This is really helpful.