note 63741 deleted from language.operators.string by hholzgra

From: Date: Thu, 02 Aug 2012 15:17:25 +0000
Subject: note 63741 deleted from language.operators.string by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189843@lists.php.net to get a copy of this message
Note Submitter: caliban at darklock dot com ---- WRT Stephen's note: My example of concatenation and array methods of string building does not include the interstitial logic, which is expected to include conditionals. Concatenation method: $str="This is my list"; if($list=="o") $str.="<ol>"; else $str.="<ul>"; foreach($item as $i) $str.="<li>$i</li>"; if($list=="o") $str.="</ol>"; else $str.="</ul>"; Array method: $str=array("This is my list"); if($list=="o") $str[]="<ol>"; else $str[]="<ul>"; foreach($item as $i) $str[]="<li>$i</li>"; if($list=="o") $str[]="</ol>"; else $str[]="</ul>"; $str=implode("",$str); You can't do either of these with a single double-quoted string. However, if what you are doing CAN be done in a single double-quoted string, Stephen is completely correct in observing that you should do that instead of concatenating.

« previous php.notes (#189843) next »