php重复输出字符可以参考下面的代码:
//字符串
$str= "hello,PHP!";
//将上述字符串重复10次
echo str_repeat($str, 10);
?>
扩展资料:
str_repeat() 函数的作用是把字符串重复指定的次数。
语法
str_repeat(string,repeat)
参数描述
string 必需,规定要重复的字符串。
repeat 必需,规定字符串将被重复的次数,必须大于等于 0。
实例
把字符串 "Shanghai " 重复 5 次:
echo str_repeat("Shanghai",5);
?>
php中重复输出字符可以使用str_repeat() 函数。它的作用就是把字符串重复指定的次数。或者使用循环也行。
示例代码:
//字符串
$str= "hello,PHP!
";
//将上述字符串重复10次
echo str_repeat($str, 10);
?>
运行结果:
echo str_repeat("A",5);