Skip to content

Instantly share code, notes, and snippets.

@samsargent
Last active January 31, 2016 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsargent/90e388865e78c798796f to your computer and use it in GitHub Desktop.
Save samsargent/90e388865e78c798796f to your computer and use it in GitHub Desktop.
function ordinal($number) {
$ends = array('th','st','nd','rd','th','th','th','th','th','th');
if ((($number % 100) >= 11) && (($number%100) <= 13))
return $number. 'th';
else
return $number. $ends[$number % 10];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment