php str_repeat函数怎样用?
php str_repeat()函数能够反复使用指定字符串,用于经由过程反复给定字符串牢固次数来建立新字符串,
语法:
str_repeat(string,repeat)
参数:
● string:必需参数,要反复的字符串
● repeat:必需参数,划定字符串反复的次数,必需大于即是0。
返回值:str_repeat返回一个新字符串,该字符串由给定次数反复给定字符串$ string构成。假如通报给函数的参数$ no_of_times即是0,则该函数返回一个空字符串。
示例
<?php $i = "hello world!"; $j = str_repeat($i,3);//设置字符串反复的次数为3 echo $j; ?>
输出:
hello world!hello world!hello world!
以上就是php str_repeat函数怎样用?的细致内容,更多请关注ki4网别的相干文章!