public static function NumDelim num delim explode num ans len strlen a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
public static function NumDelim($num, $delim = ' ') {
$a = explode('.', $num);
$ans = '';
$len = strlen($a[0]);
$ans .= substr($a[0], 0, ($len % 3)? $len % 3 : 3);
for ($i = ($len % 3)? $len % 3 : 3; $i < $len; $i += 3)
$ans .= $delim.substr($a[0], $i, 3);
$ans.='.'.$a[1];
return $ans;
}