2

Is it possible to get only the suffix of a number with the NumberFormatter class in PHP.

For example:

$nf = new NumberFormatter( 'en', NumberFormatter::ORDINAL );
$out = $nf->format( 10000 );
echo $out . "\n";

Will result in: '10,000th'

I would just like: 'th', i.e. the suffix.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Kohjah Breese
  • 4,008
  • 6
  • 32
  • 48

1 Answers1

3

I don't believe that is possible with NumberFormatter, the best you could do would be to grab the last two characters:

echo substr($out, -2);

Otherwise skip NumberFormatter and find the suffix a different way

Community
  • 1
  • 1
John C
  • 8,223
  • 2
  • 36
  • 47