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

Posted by Hero Wanders on 09/30/05 03:48

Hello!

> preg_match("/PPC/i", "$agent")
^ ^

IMO you should use >$agent< instead of >"$agent"<.
Furthermore you are only doing a check whether one string is in another.
Use stripos (PHP5), strpos in combinanation with strtolower or stristr
for this.
IIRC the second is the fastest for PHP4.

if (strpos(strtolower($agent), 'ppc') !== false) {
// ...
}

http://php.net/strpos
http://php.net/stripos
http://php.net/strstr
http://php.net/stristr
http://php.net/strtolower

Greetings,
Hero Wanders

 

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

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