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函数怎么用?的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于phpstr_repeat函数怎么用?的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did62457