Case statement

I am a new to php. I am fairly new to programming. I have used case statements in visual basic and vba. The syntax looks different in php. Here is what I have I get an error on line 11 which is the start of the case statement.

Moon Phases <?php $months= array('Jan', 'Feb', 'Mar', 'Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec',); $number = rand(0,11) switch ($number) { case 0: echo "Jan"; break; case 1: echo "Feb"; case 2: echo "Mar"; break; case 3: echo "Apr"; break; case 4: echo "May"; break; case 5: echo "Jun"; break; case 6: echo "Jul"; break; case 7: echo "Aug"; break; case 8: echo "Sep"; break; case 9: echo "Oct"; break; case 10: echo "Nov"; break; case 11: echo "Dec"; break; default: echo "Other"; }

?>

You need a semicolon after the rand() function above it.

Thank you Smokey. I did not see that at all. That was easy.

Sponsor our Newsletter | Privacy Policy | Terms of Service