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
---John Holmes...
Code: <?php
function gt() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); }
$str = 'It\'s, all! ok? asd? asdf! " and " wosz';
$s1 = gt(); for($i = 0; $i < 50000; $i++) { str_replace(array('.',',','!','?','"','\''),'',$str); } $e1 = gt();
$s2 = gt(); for($i = 0; $i < 50000; $i++) { ereg_replace("[.,!?\"']",'',$str); } $e2 = gt();
echo 'str_replace: ' . ($e1 - $s1) . '<br />ereg_replace: ' . ($e2-$s2);
?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php