note 34210 added to ref.strings
| From: | lille dot findus at telia dot com | Date: | Fri, 18 Jul 2003 11:59:36 +0000 |
| Subject: | note 34210 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52334@lists.php.net to get a copy of this message | ||
The first function to return 1st, 2nd etc was very ineffective, the second one don't work (try
21 for example).
Here's one that works(not too optimized though):
function nth($in)
{
if(strlen($in)>1 && substr($in,-2,1)==1)
return $in."th";
switch(substr($in,-1,1))
{
case 1:
return $in."st";
case 2:
return $in."nd";
case 3:
return $in."rd";
default:
return $in."th";
}
}
----
Manual Page -- http://www.php.net/manual/en/ref.strings.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34210
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34210&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34210&report=yes