note 48215 added to language.operators.string

From: Date: Wed, 15 Dec 2004 15:57:27 +0000
Subject: note 48215 added to language.operators.string
Groups: php.notes 
Request: Send a blank email to php-notes+get-81823@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/language.operators.string.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48215 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48215&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48215&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48215&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48215&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48215&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48215&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48215&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81823) next »