tags:

views:

49

answers:

1

I have the following number 353711000 and I need to convert it to 35371TH in PHP.

How would I go about this?

+1  A: 

Without regular expressions:

$i = 353711000;
if ($i % 1000 == 0) {
    $s = strval($i / 1000) . 'TH';
} else {
    $s = strval($i);
}
print_r($s);
Mark Byers
Good answer, could use `intval($x / 1000) . "TH";` if it won't necessarily end in 0's.
Brandon Horsley