RE: [PHP] switch statement question
| From: | Jay Blanchard | Date: | Tue, 13 Aug 2002 15:53:12 +0000 |
| Subject: | RE: [PHP] switch statement question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-112348@lists.php.net to get a copy of this message | ||
[snip]
Say i have a variable $string_var = "Once upon a time";
is there a way to do this:
Switch($string_var)
{
case(contains "Once"):
doSomething();
break;
case(contains "the end.")
doOtherThing();
break;
case(contains "time")
doNothing();
break;
default:
echo "ERROR"
}
[/snip]
http://www.php.net/manual/en/control-structures.switch.php
Yes Virginia, there is a PHP function :^]. You can explode your $string_var
into an array, loop through the array and test each word for a match.
HTH!
Jay