0
 <?php $san= "" ;  $year = 2013 ;
switch (($year - 7) % 12) {
case 0:$san = "rat" ; break ;
case 1:$san = "tiger" ; break ;
case 2:$san = "elephant" ; break ;
case 3:$san = "sneake" ; break ;
case 4:$san = "dog" ; break ;
case 5:$san = "cat" ; break ;
case 6:$san = "roar" ; break ;
case 7:$san = "keke" ; break ;
case 8:$san = "weiki" ; break ;
case 9:$san = "liki" ; break ;
case 10:$san = "ziki" ; break ;
case 11:$san = "hump" ; break ;
echo ucwords("The year {$year} is the year of {$san} <br/>") ;
break ;
default:
echo "the year {$year} not listed <br/>" ;
break;
} 
3
Contributors
3
Replies
18
Views
6 Days
Discussion Span
Last Post by diafol
1

You could try an array as an alternative, e.g.:

function animal( $year )
{
    $sub = 7;
    $yearAni = ['rat','tiger','elephant','snake','dog','cat','roar','keke','weiki','liki','ziki','hump'];
    $index = ($year-$sub) % count($yearAni);
    return $yearAni[$index];
}

for($y=2000;$y<=2017;$y++)
    echo ucwords("The year $y is the year of the " . animal($y) . "<br />");
Votes + Comments
I'll cue up "In the Year 2525" and hope the OP can support more years.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.