function ordinal ($num
{
// get the last two digits
$last = $num % 100;
// get last digit unless the number is in the teens
$last = ($last < 20) ? $last : $num % 10;
$ord = ($last==1) ? 'st' : (($last==2) ? 'nd' : (($last==3) ? 'rd' : 'th'));
return $num$ord
}
eXorithm – Execute Algorithm: View / Run Algorithm ordinal
