note 39739 deleted from function.strtr by irchtml

From: Date: Thu, 04 Mar 2004 13:14:27 +0000
Subject: note 39739 deleted from function.strtr by irchtml
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-66237@lists.php.net to get a copy of this message
Note Submitter: cristiano.verondini@mail.ing.unibo.it ---- 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);

« previous php.notes (#66237) next »