PHP字符串问题

Cen*_*ion 2 php string

我只有一个问题,让我说我有$var="z"和如何连接z $ i次,例如,如果$i==5那么$ var应该是"zzzzz".顺便说一句,我需要一行.

Gum*_*mbo 11

用途str_repeat:

$repeated = str_repeat($var, $i);
Run Code Online (Sandbox Code Playgroud)

$var是重复$i次数.


Art*_*cto 5

你用str_repeat.在你的情况下:

str_repeat($var, $i);
Run Code Online (Sandbox Code Playgroud)