note 107518 added to control-structures.switch
| From: | Anonymous | Date: | Tue, 14 Feb 2012 21:39:03 +0000 |
| Subject: | note 107518 added to control-structures.switch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186137@lists.php.net to get a copy of this message | ||
Rewriting the function (to be three times faster) provided by [stever at ashomecare dot com
07-Sep-2007 09:11] and demonstrating points that others have made:
<?php
function getChineseZodiac($year){
switch ($year % 12) :
case 0: return 'Monkey'; // Years 0, 12, 1200, 2004...
case 1: return 'Rooster';
case 2: return 'Dog';
case 3: return 'Boar';
case 4: return 'Rat';
case 5: return 'Ox';
case 6: return 'Tiger';
case 7: return 'Rabit';
case 8: return 'Dragon';
case 9: return 'Snake';
case 10: return 'Horse';
case 11: return 'Lamb';
endswitch;
}
echo getChineseZodiac(2016);
?>
----
Server IP: 69.147.83.197
Probable Submitter: 72.219.151.91
----
Manual Page -- http://www.php.net/manual/en/control-structures.switch.php
Edit -- https://master.php.net/note/edit/107518
Del: integrated -- https://master.php.net/note/delete/107518/integrated
Del: useless -- https://master.php.net/note/delete/107518/useless
Del: bad code -- https://master.php.net/note/delete/107518/bad+code
Del: spam -- https://master.php.net/note/delete/107518/spam
Del: non-english -- https://master.php.net/note/delete/107518/non-english
Del: in docs -- https://master.php.net/note/delete/107518/in+docs
Del: other reasons-- https://master.php.net/note/delete/107518
Reject -- https://master.php.net/note/reject/107518
Search -- https://master.php.net/manage/user-notes.php