Created
June 5, 2014 10:52
-
-
Save dannyockilson/79865d873bf8575bd52c to your computer and use it in GitHub Desktop.
Add "Ordinal Suffix" to a number (ie 1->1st)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iadw_get_ordinal_suffix($number){ | |
$ends = array('th','st','nd','rd','th','th','th','th','th','th'); | |
if (($number %100) >= 11 && ($number%100) <= 13) | |
$abbreviation = $number. 'th'; | |
else | |
$abbreviation = $number. $ends[$number % 10]; | |
return $abbreviation; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment