note 86203 modified in function.is-numeric by felipe
| From: | felipe@php.net | Date: | Fri, 10 Oct 2008 19:32:17 +0000 |
| Subject: | note 86203 modified in function.is-numeric by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145254@lists.php.net to get a copy of this message | ||
"$e = (int) substr( $n , -2 );"
What the heck am I thinking.
<?php
function number_suffix2($n)
{
$s = array( 1->'st' , 2=>'nd' , 3=>'rd' );
$e = $n % 100;
$x = $n % 10;
return $n.( ( $x > 0 && $x < 4 && ( $e < 11 || $e > 13 ) ) ? $s[$x]
: 'th' );
}
?>
--was--
"$e = (int) substr( $n , -2 );"
What the heck am I thinking.
function number_suffix2($n)
{
$s = array( 1->'st' , 2=>'nd' , 3=>'rd' );
$e = $n % 100;
$x = $n % 10;
return $n.( ( $x > 0 && $x < 4 && ( $e < 11 || $e > 13 ) ) ? $s[$x]
: 'th' );
}
http://php.net/manual/en/function.is-numeric.php