str_repeat()函数用于把字符串重复指定的次数。
str_repeat ( string $string , int $repeat)
它用于将字符串(string)重复指定(repeat)的次数。
它返回重复的字符串
| 序号 | 参数与说明 |
|---|---|
| 1 | string 它指定要重复的字符串 |
| 2 | repeat 它指定字符串重复的次数 |
试试下面的实例,将字符串“nhooo”重复5次和字符串“-=”重复10次:
<?php
//将字符串“(cainiaoplus.com) ”重复5次。
echo str_repeat("(cainiaoplus.com) ",5);
echo '<br>';
//将字符串-=重复10次。
echo str_repeat("-=", 10);
?>测试看看‹/›输出结果
(cainiaoplus.com) (cainiaoplus.com) (cainiaoplus.com) (cainiaoplus.com) (cainiaoplus.com) -=-=-=-=-=-=-=-=-=-=