I used Java for a long time as a standard method for creating long strings in parts, to add elements to an array and then explode the array.
$out[] = 'a'; $out[] = 'b'; echo implode('', $out);
But then with lots of data.
An alternative (standard PHP) is to use string concatenation.
$out = 'a'; $out .= 'b'; echo $out;
To my surprise, there is no speed difference between the two methods. When there is a significant time difference, it is usually a concatenation that seems faster, but not all the time.
So my question is: are there any other reasons for choosing one approach over another, besides reading styles and code?
string arrays php
Matijs
source share