it looks like you're getting your ereg and preg mixed up but try it
like this:
switch(1){
case ereg("\\.jpg$",$filename):
echo "JPEG Image";break;
case ereg("\\.gif$",$filename):
echo "GIF Image";break;
case ereg("\\.zip$",$filename):
echo "Compressed File"; break;
default:
echo "Unkown File Type"; break;
}
thats maybe a little cleaner than using if/else if's. also be careful
on the backslash, you have to escape it in double quotes.
On Tue, 19 Jun 2001 18:48:03 -0400, TunkeyMicket
([EMAIL PROTECTED]) wrote:
> Humor me, how useful would a Regex switch statement be?
>
> Like:
>
> ereg_switch($filename) {
> case "/\.jpg$/":
> echo "JPEG Image"; break;
> case "/\.gif$/";
> echo "GIF Image"; break;
> case "/\.zip$/":
> echo "Compressed File"; break;
> default:
> echo "Unkown File Type"; break;
> }
>
> That is just an example of an application of such, I have other
>applications that I would like to use it for, but that serves the
>best example. I would love to get started on a module project for
>something like this, as using IF blocks with PREG_MATCH become
>tedious and inefficient. If you know of such a module or would
>know how to get started, please repsond with your ideas/input.
>
> Chris "TunkeyMicket" Watford
> --------------------------------------------
> TunkeyMicket Productions
> www.tunkeymicket.com
>