function dna_ordinal( $number ) { // e.g. echo dna_ordinal(92); will print '92nd' $ends = array ( 'th' , 'st' , 'nd' , 'rd' , 'th' , 'th' , 'th' , 'th' , 'th' , 'th' ); if ((( $number % 100) >= 11) && (( $number %100) <= 13)) { $output = $number . 'th' ; } else { $output = $number . $ends [ $number % 10]; } return $output ; } |