Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Keith Devens:
Building Large Strings in PHP
Jul 05, 2004 @ 11:40:54

Building large strings in PHP

Note to PHP programmers: It turns out it's much faster to build large strings from many smaller strings by concatenating them onto one string than it is to append to an array repeatedly and then join that array into a string. I timed it and was surprised by the results.

I am not too surprised at this. I find myself using arrays for this when I need to join(', ', $array). It's lazy, but it works.

tagged:

Link:


Trending Topics: