|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-04-18 17:45 UTC] aharvey@php.net
-Status: Open
+Status: Wont fix
[2013-04-18 17:45 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 04:00:01 2025 UTC |
Description: ------------ str_tr is 5-10% faster than str_replace. You should mention it in documentation or make str_replace as fast as str_tr Test script: --------------- <?php function f1() { for($i=0; $i<1000000; ++$i) { $new_string = strtr("http://onlinecasinosdoc.com.au/", ".com", ""); } } function f2() { for($i=0; $i<1000000; ++$i) { $new_string = str_replace("http://onlinecasinosdoc.com.au/", ".com", ""); } } $start = microtime(true); f1(); $stop = microtime(true); $time1 = $stop - $start; $start = microtime(true); f2(); $stop = microtime(true); $time2 = $stop - $start; echo $time1 . "\t"; echo $time2 . "\n"; Expected result: ---------------- This behavior should be mentioned in documentation Actual result: -------------- You don't understand what is the difference between strtr and str_replace