AndreaD wrote:
Looking for the most code efficient way to do multiple boolean OR's on one line

if ($name==andrea) OR ($name==john)

If you put an opening brace after that, you'll get a parse error. You're also treating andrea and john as constants, which I'm guessing isn't what you mean. I think you were wanting:


if ($name == 'andrea' || $name == 'john')

If you have a bunch of these conditions, a switch might be convenient:

switch ($name)
{
    case 'andrea':
    case 'john':
    case 'chris':
    case 'rasmus':
    case 'andi':
    case 'zeev':
        echo 'The name was one of those';
        break;
    default:
        echo 'The name wasn't one of those';
}

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to