John Nichel wrote:
Jason Davidson wrote:
i think str_replace is faster that ereg_replace
Jason
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.
Around 1/10th of a second difference in 100,000 replaces....
<?php
function getmicrotime() {
list( $usec, $sec ) = explode( " ", microtime() );
return ( ( float ) $usec + ( float ) $sec );
}
$string = "Foo is a common term used in programming.";
$start = getmicrotime();
for ( $i = 0; $i < 100000; $i++ ) {
preg_replace ( "/Foo/", "Bar", $string );
}
$stop = getmicrotime();
$preg = $stop - $start;
$start = getmicrotime();
for ( $i = 0; $i < 100000; $i++ ) {
str_replace ( "Foo", "Bar", $string );
}
$stop = getmicrotime();
$strreplace = $stop - $start;
echo ( "PREG : " . $preg . "<br />\nSTR_ : " . $strreplace );
?>
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php