Created
May 18, 2016 13:23
-
-
Save postpostscript/12fc6cad630c34c5cd3ad48071ecf90d to your computer and use it in GitHub Desktop.
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
<?php | |
function ordinal_suffix($n) { | |
$j = $n % 10; | |
$k = $n % 100; | |
if (!($k >= 11 && $k <= 19)) { | |
switch($j) { | |
case 1: | |
return "st"; | |
case 2: | |
return "nd"; | |
case 3: | |
return "rd"; | |
} | |
} | |
return "th"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment