note 40460 added to function.strtr
| From: | timwarden at rn2 dot php dot net | Date: | Thu, 04 Mar 2004 13:12:09 +0000 |
| Subject: | note 40460 added to function.strtr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66236@lists.php.net to get a copy of this message | ||
to the gentlemen commenting on execution times of strtr() vs. str_replace(). i just tried the two
routines under identical circumstances, and my results were quite the opposite of yours. strtr()
was significantly faster than str_replace().
it would also seem that in cristiano's example below, you pay a hefty penalty using the
original $tr array to create the $to and $from arrays
in that for loop.
i realize that benching is both an art and a science, but any clarification of your measurements
would be appreciated... (i.e. in your tests, how many elements in the translation arrays? avg size
of those strings? avg size of the source strings?
tim
----
Manual Page -- http://www.php.net/manual/en/function.strtr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40460
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40460&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40460&report=yes
Search -- http://master.php.net/manage/user-notes.php