Considering the codes below:
$str = '';
for ($i = 30000; $i > 0; $i--) {
$str .= 'STRING QUALQUER, ';
}
$str = subtr($str,0,-2);
and this
$sArr = array();
for ($i = 30000; $i > 0; $i--) {
$sArr[] = 'STRING QUALQUER';
}
$str = implode(", ",$sArr);
Considering the performance, what form will have the lowest processing cost?
I found in a legacy code these two ways to do the same thing.
memory_limit
is a factor? through my search I did not find anything, in the PHP manual about implode () and subtr () only shows usage detail.
says that doing " implode usually takes two times more than the standard concatenation operator ", but substr () would also have to go through the string to make the cut, right?