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
  • 34,719
  • 24
  • 185
  • 251
Kohjah Breese
  • 3,772
  • 5
  • 30
  • 44

1 Answers1

2

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,058
  • 2
  • 36
  • 46