Number Format
Format a number with grouped thousands(please visit number_format
in php):
function numberformat($str, $sep=',') { $result = ''; $str = $str.''; $c = 0; $num = strlen($str); for($i=$num-1; $i>=0; $i--) { if($c==3) { $result = $sep.$result; $result = $str[$i].$result; $c = 0; } else { $result = $str[$i].$result; } $c++; } return $result; } //OUT = 1,333,555 echo numberformat(1333555);