note 62159 deleted from control-structures.switch by nlopess
| From: | nlopess@php.net | Date: | Tue, 21 Feb 2006 22:15:19 +0000 |
| Subject: | note 62159 deleted from control-structures.switch by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-104165@lists.php.net to get a copy of this message | ||
Note Submitter: nate
----
if you need to operate on the switch variable in the case statements you can access it as
$_.
For example, I was using switch to iterate over a set of mime types and I wanted to catch the
image\* types.
To do that I wrote this clause:
switch($mime){
case(preg_match('/image.*/', $_)):
...put code here...
break;
}
This tip may seem obvious to the experienced user, but not so obvious to the beginner.