Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19007 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39043 invoked by uid 1010); 15 Sep 2005 20:50:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 39027 invoked from network); 15 Sep 2005 20:50:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Sep 2005 20:50:51 -0000 X-Host-Fingerprint: 209.151.233.3 jekyll.safesearching.com Linux 2.4/2.6 Received: from ([209.151.233.3:59969] helo=jekyll.safesearching.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id D9/07-41173-AAED9234 for ; Thu, 15 Sep 2005 16:50:50 -0400 Received: (qmail 26102 invoked from network); 15 Sep 2005 13:50:46 -0700 Received: from adsl-67-112-238-195.dsl.lsan03.pacbell.net (HELO ?192.168.1.136?) (67.112.238.195) by jekyll.safesearching.com with SMTP; 15 Sep 2005 13:50:46 -0700 Message-ID: <4329E054.8070206@safesearching.com> Date: Thu, 15 Sep 2005 13:57:56 -0700 User-Agent: Mozilla Thunderbird 1.0+ (Windows/20050531) MIME-Version: 1.0 To: Ron Korving CC: internals@lists.php.net References: <42FCE0E4.604@lerdorf.com> <43281520.4000209@metropolis-ag.de> <4E.EA.41173.2CBB9234@pb1.pair.com> In-Reply-To: <4E.EA.41173.2CBB9234@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 6.0 Wishlist From: james@safesearching.com (James Crumpton) 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