I don't know of any built-ins that do this, but this should work:
function ordinal_suffix($num){
$num = $num % 100; // protect against large numbers
if($num < 11 || $num > 13){
switch($num % 10){
case 1: return 'st';
case 2: return 'nd';
case 3: return 'rd';
}
}
return 'th';
}
(note 11, 12 and 13 are special cases - 11th, 12th, 13th vs 11st...)