me'
04-12-2004, 07:30 PM
http://www.codingforums.com/showthread.php?p=178925#post178925
A beautiful javascript function as the result of the best minds on this forum coming together, but I'm trying to rewrite it in PHP. Maybe because I don't fully understand the Javascript in it, but this function always seems to return 'th'.function add_ordinals($num){
$ords = array ( "th","st","nd","rd" );
return
$num . $ords[(!((($num=this%10) >3) || (floor(this%100/10)==1))) * $num];
}Any help in debugging is appreciated.
A beautiful javascript function as the result of the best minds on this forum coming together, but I'm trying to rewrite it in PHP. Maybe because I don't fully understand the Javascript in it, but this function always seems to return 'th'.function add_ordinals($num){
$ords = array ( "th","st","nd","rd" );
return
$num . $ords[(!((($num=this%10) >3) || (floor(this%100/10)==1))) * $num];
}Any help in debugging is appreciated.