Last active
October 19, 2016 11:44
-
-
Save bwente/8967553 to your computer and use it in GitHub Desktop.
MODx output filter, converts cardinal to ordinal.
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 | |
$test_c = abs($input) % 10; | |
$ext = ((abs($input) %100 < 21 && abs($input) %100 > 4) ? 'th' | |
: (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1) | |
? 'th' : 'st' : 'nd' : 'rd' : 'th')); | |
return $input.$ext; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment