note 41491 added to ref.strings
| From: | michael at rn2 dot php dot net | Date: | Mon, 12 Apr 2004 15:27:40 +0000 |
| Subject: | note 41491 added to ref.strings | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68020@lists.php.net to get a copy of this message | ||
Alternative (slightly better and smaller) 'ordinal numbers' fuction (see missnglnk at
missnglnk dot com's message for previous version, fuction is named 'nth'):
<?php
/*
* function ordialise ($n)
* returns the 'ordinal number' of $n.
*/
function ordinalize ($n) {
switch (substr($n,-1)) {
case 1: return $n.'st';
case 2: return $n.'nd';
case 3: return $n.'rd';
default: return $n.'th';
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/ref.strings.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41491
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41491&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41491&report=yes
Search -- http://master.php.net/manage/user-notes.php