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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx> wrote in message 
> news:1286892056.20110429010146@xxxxxxxxxxxxxxxx
> > 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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux