str_repeat()函數(shù)用于把字符串重復(fù)指定的次數(shù)。
str_repeat ( string $string , int $repeat)
它用于將字符串(string)重復(fù)指定(repeat)的次數(shù)。
它返回重復(fù)的字符串
| 序號(hào) | 參數(shù)與說(shuō)明 |
|---|---|
| 1 | string 它指定要重復(fù)的字符串 |
| 2 | repeat 它指定字符串重復(fù)的次數(shù) |
試試下面的實(shí)例,將字符串“nhooo”重復(fù)5次和字符串“-=”重復(fù)10次:
<?php
//將字符串“(cainiaoplus.com) ”重復(fù)5次。
echo str_repeat("(cainiaoplus.com) ",5);
echo '<br>';
//將字符串-=重復(fù)10次。
echo str_repeat("-=", 10);
?>測(cè)試看看?/?輸出結(jié)果
(cainiaoplus.com) (cainiaoplus.com) (cainiaoplus.com) (cainiaoplus.com) (cainiaoplus.com) -=-=-=-=-=-=-=-=-=-=