Switch statements work well for these situations as well.  They might be
faster than checking for the item in a list from an array since an array
must be created and searched through.

General programming tip: your method *definitely* wouldn't work.  The or
operator has precendence over the == operator, causing those clauses to be
broken up like this:

$ext=="com"
"net"
"org"
"info"

Only one of those statements needs to be evaluated to true for the contents
of the if statement to be evaluated.  The first one will only be true if
that's what's inside $ext.  The others will always evaluate to true since a
string of anything is considered "true" as a boolean.

As a switch:

> If($ext=="com"or"net"or"org"or"info"){
> Then do this
> }

switch($ext)
{
    case "com":
    case "net":
    case "org":
    case "info":
    // then do this
    break;
}

Your friendly PHP manual will give you more information on the use of
switches.  They're useful for more than just this kind of situation (namely
when you want to process many possible inputs for one variable).

-Adam


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to