note 41491 deleted from ref.strings by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 12 Apr 2004 15:43:45 +0000 |
| Subject: | note 41491 deleted from ref.strings by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-68022@lists.php.net to get a copy of this message | ||
Note Submitter: michael
----
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';
}
}
?>