note 13351 added to function.str-replace.php
| From: | a2zofciv2 at hotmail dot com | Date: | Tue, 12 Jun 2001 23:00:15 +0000 |
| Subject: | note 13351 added to function.str-replace.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14287@lists.php.net to get a copy of this message | ||
I noticed that every time i do a replace on a string pattern with a function that returns a string,
the functions gets executed whether the pattern is found or not! this significantly impacts runtime
if you are a doing a looping replace (like i was) and if the function is large so be careful.
example of what i'm talking about:
$line = str_replace("PATTERN", replacement(), $line);
my solution-> make a variable = replacement() before the loop.
http://www.php.net/manual/en/function.str-replace.php