Re: Remove punctuation

From: Date: Thu, 09 Sep 2004 21:01:21 +0000
Subject: Re: Remove punctuation
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-196257@lists.php.net to get a copy of this message
* Thus wrote John Holmes: > From: "John Nichel" <john@kegworks.com> > >>i think str_replace is faster that ereg_replace > > > >We tested that theory a while back on here (I don't remember the subject > >of the emails, so finding it would be kind of hard), and it came out to be > >almost exactally the same speed. > > Not that speed tests like this really matter in the long run of your code, > but: > > str_replace: 0.26480603218079 > ereg_replace: 0.61685109138489 > > preg_replace came in at about 0.4, btw I betya strtr() will win over them all :) Also, results will vary greatly with a string like: $str = "''''''''''''''''''''''''''''''''''''"; str_replace will fall down closer to preg. > > str_replace(array('.',',','!','?','"','\''),'',$str); Curt -- The above comments may offend you. flame at will.

« previous php.general (#196257) next »