Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
strtr versus str replace which have you found to be faster? lethal0r msg:3937689 12:57 pm on Jun 21, 2009 (gmt 0) in working on optimizing my website I have read many posts on these 2 functions, and it seems to be split down the middle as to which is faster.
in my case I found that if you need to check for many replacements in one go, then strtr is faster. for example I am doing this kind of thing
$text = strtr($text, array('é' => 'e', 'È' => 'E', 'Â' => 'A'));
plus another 20 replacements or so. I tested both functions 10 times each and strtr was faster 8 times.
I would be interested to hear any one elses experiences here!
coopster msg:3938161 12:38 pm on Jun 22, 2009 (gmt 0)
I've never measured one against the other for speed/performance but you may also add a regular expression to your tests to see how that performs too. The regular expression engine in the latest PHP5 releases has been quite impressive.