note 48215 deleted from language.operators.string by hholzgra

From: Date: Thu, 02 Aug 2012 15:17:03 +0000
Subject: note 48215 deleted from language.operators.string by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189842@lists.php.net to get a copy of this message
Note Submitter: caliban at darklock dot com ---- String concatenation is faster than the array method: $str=""; $str.="Some string"; $str.="Some other string"; ... $str.="The last string"; That runs roughly twice as fast as: $str=array(); $str[]="Some string"; $str[]="Some other string"; ... $str[]="The last string"; $str=implode("",$str); Not that I think this is a terribly widespread practice, but I've got an awful lot of legacy code with this array method in it and a comment to the effect that it's faster than string concatenation. Testing has shown the exact opposite, so I figured I'd enlighten anyone else with this misconception.

« previous php.notes (#189842) next »