note 62355 rejected from control-structures.switch by betz
| From: | betz@php.net | Date: | Wed, 29 Mar 2006 02:20:32 +0000 |
| Subject: | note 62355 rejected from control-structures.switch by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106895@lists.php.net to get a copy of this message | ||
Note Submitter: brad at qiqsand dot com
----
Normally, one places a variable in the switch expression to be compared to any number of expicit
values in the case expressions. This is how it is documented above and how it is described in all
books I have read. However, you can evaluate any expression in the switch expression to match any
expression in the case expressions. Most notably, when you have a permutation of values that must be
checked you can simply put TRUE in the switch expression and any complex expression that returns
TRUE (or FALSE) in the case expressions. I did not see this in the documentation or in any books I
have read, but it is extremely useful. (I had a nicer post with some nice example code, but this
system gobbled all the returns into the ascii values creating too long lines.)