Not necessarily.
What you need to do is create a table relating digits to suffixes, and conditionally insert the appropriate suffix.
You could do it with an array. Something like:
// make an array of suffixes for numbers
$suffix = array('th','st','nd','rd','th','th','th','th','th','th');
// pick a number, any number
$mynumber = 240;
//
echo "Today is the ", $mynumber, $suffix[substr($mynumber,-1)], " day of the year.";
You can obtain the rightmost column from any large number by using substr() because PHP internally stores all values as strings.