str_replace vs. preg_replace speed
| From: | Shawn McKenzie | Date: | Wed, 17 Dec 2003 05:02:53 +0000 |
| Subject: | str_replace vs. preg_replace speed | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-172855@lists.php.net to get a copy of this message | ||
I will run some benchmarks (even though they may be flaky), but what would
be the fastest execution?
$search = array(
"<!-- [$cmd] -->",
"<!--[$cmd]-->",
"<!-- {".$cmd."} -->",
"<!--{".$cmd."}-->",
"{".$cmd."}",
);
$replace = STARTPHP." $action ".ENDPHP;
$tmpcontent = str_replace($search, $replace, $tmpcontent);
Or, if I created one expression that handled all of the five $search items
(since they are similar) and used preg_replace()?
Thanks!
-Shawn