You are here: Re: conditional preg match « PHP Programming Language « IT news, forums, messages
Re: conditional preg match

Posted by Oli Filth on 09/30/05 02:16

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация