note 112959 added to function.strtr

From: Date: Mon, 12 Aug 2013 16:01:25 +0000
Subject: note 112959 added to function.strtr
Groups: php.notes 
Request: Send a blank email to php-notes+get-195940@lists.php.net to get a copy of this message
The example of VOVA (http://www.php.net/manual/fr/function.strtr.php#111968) is good but the result is false: His example dont replace the string. <?php function f1_strtr() { for($i=0; $i<1000000; ++$i) { $new_string = strtr("aboutdealers.com", array(".com" => "")); } return $new_string; } function f2_str_replace() { for($i=0; $i<1000000; ++$i) { $new_string = str_replace( ".com", "", "aboutdealers.com"); } return $new_string; } $start = microtime(true); $strtr = f1_strtr(); $stop = microtime(true); $time_strtr = $stop - $start; $start = microtime(true); $str_replace = f2_str_replace(); $stop = microtime(true); $time_str_replace = $stop - $start; echo 'time strtr : ' . $time_strtr . "\tresult :" . $strtr . "\n"; echo 'time str_replace : ' . $time_str_replace . "\tresult :" . $str_replace . "\n"; echo 'time strtr > time str_replace => ' . ($time_strtr > $time_str_replace); ?> -------------------------------------- time strtr : 3.9719619750977 result :aboutdealers time str_replace : 2.9930369853973 result :aboutdealers time strtr > time str_replace => 1 str_replace is faster than strtr ---- Server IP: 69.147.83.199 Probable Submitter: 90.83.108.121 ---- Manual Page -- http://php.net/manual/en/function.strtr.php Edit -- https://master.php.net/note/edit/112959 Del: integrated -- https://master.php.net/note/delete/112959/integrated Del: useless -- https://master.php.net/note/delete/112959/useless Del: bad code -- https://master.php.net/note/delete/112959/bad+code Del: spam -- https://master.php.net/note/delete/112959/spam Del: non-english -- https://master.php.net/note/delete/112959/non-english Del: in docs -- https://master.php.net/note/delete/112959/in+docs Del: other reasons-- https://master.php.net/note/delete/112959 Reject -- https://master.php.net/note/reject/112959 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195940) next »