note 29236 deleted from function.date by philip
| From: | philip@php.net | Date: | Sat, 02 Aug 2003 15:45:02 +0000 |
| Subject: | note 29236 deleted from function.date by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-53214@lists.php.net to get a copy of this message | ||
Note Submitter: something_awesome@yahoo.com
----
Here's another suffix creater, that I think does the job in fewer lines, if that is in any way
an advantage ;-)
given $date is in MySQL format yyyy-mm-dd
===
list ($year, $month, $day) = split ('-', $date);
$prefix = array(1 => 'st', 21 => 'st', 31 => 'st', 2 =>
'nd', 22 => 'nd', 3 => 'rd', 23 => 'rd');
$day = ($day * 1); //* Kills Leading 0 *//
if ($prefix[$day]) {
$day .=$prefix[$day];
}
else {
$day .='th';
}
===
However I am unsure how the "performance" of this code compares to the example able. Is
that trick with the day more costly than using a string function on it?