Robert Kent


Personal blog of Robert Kent

PHP: Add (th, st, nd, rd, th) to the end of a number

This function will take a number and add “th, st, nd, rd, th” after it.

As of PHP 5.3.0 there is built-in functionality for this using the NumberFormatter class.