leespunten-in-getallen
Gesponsorde koppelingen
PHP script bestanden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
function addCommas($num, $crct) {
$len = strlen($num);
$str[] = substr($num, -3);
$j = -6;
for($i = -3; (($i * -1) -3) < $len; $i -=3) {
$str[] = substr($num, $j, $i) . $crct;
$j -= 3;
}
$arr = array_reverse($str);
$str = "";
foreach($arr as $var) {
$str .= $var;
}
$len = strlen($str) -1;
$str = substr($str, 1, $len);
return $str;
}
$num = 1234567892;
echo "Number org : ".$num."<br>";
echo "Number new : ".addCommas($num, ".");
?>
function addCommas($num, $crct) {
$len = strlen($num);
$str[] = substr($num, -3);
$j = -6;
for($i = -3; (($i * -1) -3) < $len; $i -=3) {
$str[] = substr($num, $j, $i) . $crct;
$j -= 3;
}
$arr = array_reverse($str);
$str = "";
foreach($arr as $var) {
$str .= $var;
}
$len = strlen($str) -1;
$str = substr($str, 1, $len);
return $str;
}
$num = 1234567892;
echo "Number org : ".$num."<br>";
echo "Number new : ".addCommas($num, ".");
?>