Skip to content

Instantly share code, notes, and snippets.

@bwente
Last active October 19, 2016 11:44
Show Gist options
  • Save bwente/8967553 to your computer and use it in GitHub Desktop.
Save bwente/8967553 to your computer and use it in GitHub Desktop.
MODx output filter, converts cardinal to ordinal.
<?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