note 27164 deleted from function.date by sniper

From: Date: Sat, 11 Oct 2003 16:51:13 +0000
Subject: note 27164 deleted from function.date by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58270@lists.php.net to get a copy of this message
Note Submitter: peter@tebault.org ---- Function to do the English ordinal suffix thing for any arbitrary number. function ordSuffix($num) { // english ordinal suffix for numbers // if second to last char is not 1 // and if end char is 1, 2, 3 then st, nd, or rd, else th // else th $sLastChar = substr($num,-1,1); $sSecondToLastChar = substr($num,-2,1); if($sSecondToLastChar != 1) { switch($sLastChar) { case 1: $suffix = "st"; break; case 2: $suffix = "nd"; break; case 3: $suffix = "rd"; break; default: $suffix = "th"; break; } } else { $suffix = "th"; } return $suffix; }

« previous php.notes (#58270) next »