Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19030 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45292 invoked by uid 1010); 16 Sep 2005 06:51:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 45277 invoked from network); 16 Sep 2005 06:51:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2005 06:51:56 -0000 X-Host-Fingerprint: 195.225.34.5 fw01.axit.nl Received: from ([195.225.34.5:8550] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 62/2F-43379-C8B6A234 for ; Fri, 16 Sep 2005 02:51:56 -0400 Message-ID: <62.2F.43379.C8B6A234@pb1.pair.com> To: internals@lists.php.net References: <42FCE0E4.604@lerdorf.com> <43281520.4000209@metropolis-ag.de> <4E.EA.41173.2CBB9234@pb1.pair.com> <4329E054.8070206@safesearching.com> Date: Fri, 16 Sep 2005 08:50:55 +0200 Lines: 53 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Posted-By: 195.225.34.5 Subject: Re: [PHP-DEV] PHP 6.0 Wishlist From: r.korving@xit.nl ("Ron Korving") 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" 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