string concat vs. join / implode [英] string concat vs. join/implode

查看:87
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆