Re: Fastest commands

From: Date: Fri, 25 Apr 2003 17:35:39 +0000
Subject: Re: Fastest commands
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145301@lists.php.net to get a copy of this message
The fastest would most likely be: $content = "one, two, three"; $thearray = array ( 'one' => '1', 'two' => '2', 'three' => '3', ); $content = str_replace(array_keys($thearray),$thearray,$content); Shawn McKenzie wrote:
Is there a list of commands or any guidance on what executes the fastest? There are some notes in some of the ereg_, preg_ and str_ function docs about which ones are faster, but what about others? Also, I want to do a replace where the search is array indices and the replace is the values of the found index. Is the following the fastest??? $content = "one, two, three"; $thearray = array ( 'one' => '1', 'two' => '2', 'three' => '3', ); foreach($thearray as $search => $replace) {
       $content = str_replace($search, $replace, $content);
} Thanks! Shawn
-- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

« previous php.general (#145301) next »