Created
June 14, 2010 19:05
-
-
Save jeremeamia/438122 to your computer and use it in GitHub Desktop.
Code Golf: Ordinal suffix
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 // Code Golf: Return a number with its ordinal suffix (eg. 31 -> 31st) | |
error_reporting(E_ALL ^ E_NOTICE); | |
function ordinal($n) | |
{ | |
return($n%=100)>10&&$n<14?th:date(S,mktime(0,0,0,0,$n%10,0)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment