note 39739 added to function.strtr
| From: | cristiano dot verondini at mail dot ing dot unibo dot it | Date: | Mon, 09 Feb 2004 10:34:26 +0000 |
| Subject: | note 39739 added to function.strtr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64874@lists.php.net to get a copy of this message | ||
strtr(() is much *slower* than str_replace() when using arrays for substitution of strings. Some
(preliminary) tests gave me a 100x (!) speedup by substituting:
$text = strtr($text, $tr);
with:
$from = array();
$to = array();
foreach ($tr as $key => $value) {
$from[] = $key;
$to[] = $value;
}
$text = str_replace($from, $to, $text);
----
Manual Page -- http://www.php.net/manual/en/function.strtr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39739
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39739&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39739&report=yes
Search -- http://master.php.net/manage/user-notes.php