|
Posted by Janwillem Borleffs on 10/20/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
Navigation:
[Reply to this message]
|