I'm trying to put comas every 3 numbers in a number... (heh can't explain things that good). Well I'm trying to do this:
123,233,444
to a number that once was this:
123233444
and I suck so it seems I can't get it working... it's probably something simple, but I haven't been working with php much, and I've lost my touch... so I need a little help... this is what I have now... which does absolutly nothing... not even 1 coma...
Code: Select all
<?php
function coma ($num) {
$length = strlen($num);
if ($length > 3) {
$len = @($length / 3);
$bye = explode (".", $len);
$t2 = $bye[0] + 1;
$t = 1;
$part = array();
while ($t != $t2) {
$part[$t - 1] = substr($num, ($length - (3 * $t)), ($length - (3 * ($t - 1))));
$t++;
}
$number = substr($num, 0, ($length - (3 * ($t - 1))));
$number += ",";
$t--;
while ($t != -1){
$number += $part[$t];
$t--;
}
}
return $number;
}
?>