Re: Re: What's faster using if else or arrays?

From: Date: Fri, 29 Apr 2011 06:01:55 +0000
Subject: Re: Re: What's faster using if else or arrays?
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-312561@lists.php.net to get a copy of this message
On Thu, 2011-04-28 at 22:12 -0400, Jim Giner wrote: > Obviously you have designed a search/decision mechanism that suits your > needs. The OP did not present a problem of such magnitude. He only asked > how to handle a decision process the most efficient way - with no mention of > higher goals such as yours. > > didn't mean to offend anyone who has made a powerful use of the array > constuct. > > "Geoff Lane" <geoff@gjctech.co.uk> wrote in message > news:1286892056.20110429010146@gjctech.co.uk... > > On Thursday, April 28, 2011, Jim Giner wrote: > > > I see no problem using in_array() for situations like this, and they can be used in conjunction with a switch if you want as well: switch(true) { case in_array($needle, array('foo','bar','wtf')): { // do something break; } case ($needle == 88): { // something else break; } } And it's still quite readable as long as you get your indentation right. -- Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#312561) next »