Re: str_replace vs. preg_replace speed

From: Date: Wed, 17 Dec 2003 06:12:31 +0000
Subject: Re: str_replace vs. preg_replace speed
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-172859@lists.php.net to get a copy of this message
For clarification, I'm looking for execution speed. In the example below, $cmd may be a 100 plus item array and I loop through the code below for each $cmd. So maybe I execute the code below 100 or more times. Thanks! -Shawn "Shawn McKenzie" <nospam@mckenzies.net> wrote in message news:20031217050221.78344.qmail@pb1.pair.com... > 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

« previous php.general (#172859) next »