/ Published in: PHP
                    
                                        
Convert an number to a position / ranking. 1 becomes 1st, 2 becomes 2nd, etc...
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
function numberToPlace($number) {
$append = ($lastNumber == '1' && $lastTwo != 11) ? 'st' : (($lastNumber == '2' && $lastTwo != 12) ? 'nd' : (($lastNumber == '3' && $lastTwo != 13) ? 'rd' : 'th'));
return $number . $append;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                