Re: PHP 6.0 Wishlist

From: Date: Fri, 16 Sep 2005 06:50:55 +0000
Subject: Re: PHP 6.0 Wishlist
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-19030@lists.php.net to get a copy of this message
Funny solution :) Not very elegant I think (no offence, coz it is a smart one), but it works. It would be nice if the language provided it.. Another problem though with my idea (and not your solution) would be that a "regcase" would have the PHP syntax rely on an external library. Ron "James Crumpton" <james@safesearching.com> schreef in bericht news:4329E054.8070206@safesearching.com... > Can be done already ... sorta. > > switch (true) { > case ($str == 'abc'): > echo "it was ABC!\n"; > break; > case (preg_match('/^[0-9]+$/i', $str)): > echo "it was a number!\n"; > break; > default: > echo "it was no number :-(\n"; > break; > } > > *shrug* > > -james > > Ron Korving wrote: > > I have another idea I came up with today: regular expression switches, but > > it would be difficult without adding to the syntax. > > > > switch ($str) > > { > > case "abc": > > echo "it was ABC!\n"; > > break; > > > > regcase "/^[0-9]+$/i": > > echo "it was a number!\n"; > > break; > > > > default: > > echo "it was no number :-(\n"; > > break; > > } > > > > Just an idea ;) > > > > Ron

« previous php.internals (#19030) next »