note 86203 modified in function.is-numeric by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
"$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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.