开发者

PHP string issue

HI all I have an issue, let say I have $var="z" and how to concatena开发者_运维问答te the z $i times, for example if $i==5 then $var should be "zzzzz". BTW I would need this in one row.


Use str_repeat:

$repeated = str_repeat($var, $i);

With this $var is repeated $i times.


You use str_repeat. In your case:

str_repeat($var, $i);


<?php echo $x = str_repeat("x", 5); // "xxxxx" // Hope it helps, one row ;)


Use

str_repeat(String, Multiplier);

EDIT: Wow am I slow ...


try str_repeat (this should be upvoted once to maintain the sequence)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜