Revision: 6562
Updated Code
at May 30, 2008 22:03 by distinctdev
Updated Code
function numberToPlace($number) { if(!is_numeric($number)) return false; $number = intval($number); $lastNumber = substr($number, -1); $lastTwo = substr($number, -2); $append = ($lastNumber == '1' && $lastTwo != 11) ? 'st' : (($lastNumber == '2' && $lastTwo != 12) ? 'nd' : (($lastNumber == '3' && $lastTwo != 13) ? 'rd' : 'th')); return $number . $append; }
Revision: 6561
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 30, 2008 15:24 by distinctdev
Initial Code
function numberToPlace($number) { if(!is_numeric($number)) return false; $number = intval($number); $lastNumber = substr($number, -1); $append = ($lastNumber == '1' && $number != 11) ? 'st' : (($lastNumber == '2' && $number != 12) ? 'nd' : (($lastNumber == '3' && $number != 13) ? 'rd' : 'th')); return $number . $append; }
Initial URL
Initial Description
Convert an number to a position / ranking. 1 becomes 1st, 2 becomes 2nd, etc...
Initial Title
Convert a number to a position / ranking
Initial Tags
number, convert
Initial Language
PHP