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" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > 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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php