string concat vs. join / implode [英] string concat vs. join/implode
问题描述
也许是一个愚蠢的问题。
------------------------- < br $> b $ b 1
-------------------------
$ str ='''';
for($ i = 0; $ i< 10; $ i ++)
$ str。= $ i;
echo $ str;
----------------------- -
2
-------------------------
$ str = array();
for($ i = 0; $ i< 10; $ i ++)
$ str [] = $ i;
echo implode('''',$ str);
------------ -------------
我认为后者会更高效,因为
的工作量更少垃圾收集器,对吗?
谢谢
-
NoWhereMan(ev)
- http://www.nowhereland.it
- http://flatpress.nowhereland.it
str ='''';
for(
i = 0;
I< 10;
Maybe a stupid question.
-------------------------
1
-------------------------
$str = '''';
for($i=0; $i<10; $i++)
$str .= $i;
echo $str;
-------------------------
2
-------------------------
$str = array();
for($i=0; $i<10; $i++)
$str[]= $i;
echo implode('''', $str);
-------------------------
I suppose the latter will be more performant because there''s less work for
the garbage collector, am I right?
thanks
--
NoWhereMan (e.v.)
-- http://www.nowhereland.it
-- http://flatpress.nowhereland.it
str = '''';
for(
i=0;
i<10;
这篇关于string concat vs. join / implode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!