note 86201 modified in function.is-numeric by danbrown

From: Date: Tue, 07 Oct 2008 23:19:31 +0000
Subject: note 86201 modified in function.is-numeric by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145146@lists.php.net to get a copy of this message
Problem with vezquex at gmail dot com's function is it will produce 211th 212nd & 213rd when it should follow the same pattern of x11th, x12th and x13th. <? function number_suffix2($n) { $s = array( 'st' , 'nd' , 'rd' ); $e = (int) substr( $n , -2 ); $x = $n % 10 - 1; return $n.( (array_key_exists( $x , $s ) && ( $e < 10 || $e > 13 ) ) ? $s[$x] : 'th' ); } ?> --was-- Problem with vezquex at gmail dot com's function is it will produce 211st 212nd & 213rd when it should follow the same pattern of x11th, x12th and x13th. function number_suffix2($n) { $s = array( 'st' , 'nd' , 'rd' ); $e = (int) substr( $n , -2 ); $x = $n % 10 - 1; return $n.( (array_key_exists( $x , $s ) && ( $e < 10 || $e > 13 ) ) ? $s[$x] : 'th' ); } http://php.net/manual/en/function.is-numeric.php

« previous php.notes (#145146) next »