codecamp

PHP str_repeat() 函数

PHP str_repeat() 函数

PHP String 参考手册 PHP String 参考手册

实例

把字符串 "." 重复 13 次:

<?php
echo str_repeat(".",13);
?>

运行实例 »

定义和用法

str_repeat() 函数把字符串重复指定的次数。


语法

str_repeat(string,repeat)

参数 描述
string 必需。规定要重复的字符串。
repeat 必需。规定字符串将被重复的次数。必须大于等于 0。

技术细节

返回值: 返回被重复的字符串。
PHP 版本: 4+


PHP String 参考手册 PHP String 参考手册
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

PHP 相关教程

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }