note 27164 added to function.date

From: Date: Mon, 25 Nov 2002 19:26:50 +0000
Subject: note 27164 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-39959@lists.php.net to get a copy of this message
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; } -- http://www.php.net/manual/en/function.date.php http://master.php.net/manage/user-notes.php?action=edit+27164 http://master.php.net/manage/user-notes.php?action=delete+27164 http://master.php.net/manage/user-notes.php?action=reject+27164

« previous php.notes (#39959) next »