Re: Switch statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



switch only checks to see if its equal. you could do one of two things. put an if statement around your switch so that your switch only applies to day hours. or list out all of either the night cases or day cases and use the default case for everything you don't define. I hope this makes sense

Steven Lamb
----- Original Message ----- From: "Dotan Cohen" <dotancohen@xxxxxxxxx>
To: "For users of Fedora Core releases" <fedora-list@xxxxxxxxxx>
Sent: Monday, December 12, 2005 11:47 AM
Subject: Switch statement


I have no problem using the switch statement when I am checking if a
variable equals a known number, like such:

<?php
switch ($hour) {
case 0:
  echo "Go to sleep.";
  break;
case 10:
  echo "Good morning.";
  break;
case 22:
  echo "Good night.";
  break;
}
?>

However, how do I do it if the variable is larger than a certain
number? For instance, I want to say "Good night" if $hour is greater
than 22?

Thanks in advance.

Dotan Cohen
http://lyricslist.com/lyrics/biography/327/martin_ricky.php
Martin, Ricky Song Lyrics and Biography

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux