Reply to Re: regular expressions conditional replace

Your name:

Reply:


Posted by Janwillem Borleffs on 10/31/96 11:16

Andrew wrote:

> Janwillem's solution is the best way to do it, but if I follow it
> correctly, if (!stristr($split[$i], "<pre>") is not optimal. <pre>
> will be at the beginning of $split[$i] so you can use if
> (substr($split[$i], 0, 5) !== '<pre>') instead. stristr() will search
> the entire string.
>
> Even if you did need to determine if <pre> is anywhere in the string
> according to the PHP manual you should "use the faster and less memory
> intensive function strpos() instead."
>

Good point, although I choose to use stristr to make a case-insensitive
match. To follow the manual's suggestion I would do it as follows:

if (false !== stripos($split[$i], "<pre>")) {
...
}


JW

[Back to original 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

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