Re: conditional preg match
- From: Oli Filth <catch@xxxxxxxxxxxxxx>
- Date: Thu, 29 Sep 2005 23:16:32 GMT
toedipper said the following on 29/09/2005 21:49:
Hello,
The following bit of code does a preg match and does something if true (sets $browser to ppcie)
Without using if then and else's how do I code it so it does not equal what it is testing for? So if it does not find ppc in the $agent then it does something else/sets it to something else?
$agent = getenv("HTTP_USER_AGENT"); if (preg_match("/PPC/i", "$agent")) { $browser = 'PPCIE'; }
What on earth's wrong with if/else?
But alternatively:
$browser = (preg_match(...)) ? 'PPCIE' : 'something else';
-- Oli .
- References:
- conditional preg match
- From: toedipper
- conditional preg match
- Prev by Date: Re: Session Management
- Next by Date: Re: PHP MySQL WHY?
- Previous by thread: conditional preg match
- Next by thread: [Announce] PHPLint 0.3 - PHP source parser and validator
- Index(es):