Re: execution time: preg vs ereg vs explode & implode

From: Date: Wed, 12 Jun 2002 18:37:16 +0000
Subject: Re: execution time: preg vs ereg vs explode & implode
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6961@lists.php.net to get a copy of this message
D'oh! What would have been my first post to this list and I had forgotten to CC it... figures. Happy to oblige. - Jon Abernathy, jon@alpineinternet.com | jon@chuggnutt.com Tim Gallagher > I *ALWAYS* forget that stupid str_replace! > Ha! > > good idea, thanks. > > -timmyg > > At 09:33 AM 6/12/2002 -0700, you wrote: > >Tim Gallagher writes: > > > Can anyone tell me if using explode is slower, or faster or nearly the > >same > > > as using preg. > > > > > > I understand that preg is faster than ereg, is this true? How much > >faster? > > > > > > here's my code, i want to take a file that has {{{ or }}} and explode on > > > both. > > > should I use preg_split instead? Would it be faster? > > > > > > > > > $ar = explode("{{{", $fileContents); > > > $ar = implode(":::", $ar); > > > $ar = explode("}}}", $ar); > > > $ar = implode(":::", $ar); > > > >Wouldn't it be quicker to use str_replace to eliminate these four steps? I'm > >thinking: > > > >$ar = str_replace( array('{{{', '}}}'), ':::', $fileContents > >); > > > > > $ar = explode(":::", $ar); > > > >Otherwise, a while back I remember a thread on one of the discussion lists > >referring to some informal benchmarks which showed explode() and split() > >(the ereg version) to be about equal in speed, and preg_split() having no > >significant speed advantage over either. Of course, take this with a grain > >of salt. I myself almost always use split(). > > > > > >- Jon Abernathy, jon@alpineinternet.com | jon@chuggnutt.com > >

« previous php.pear.dev (#6961) next »