<?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;
} 

i need help its not working ??

Member Avatar for diafol

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 />");
commented: I'll cue up "In the Year 2525" and hope the OP can support more years. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.