Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function ordinal($number) {
$ends = array('th','st','nd','rd','th','th','th','th','th','th');
$mod100 = $number % 100;
return $number . ($mod100 >= 11 && $mod100 <= 13 ? 'th' : $ends[$number % 10]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.