str_repeat

(PHP 4, PHP 5, PHP 7, PHP 8)

str_repeat重复一个字符串

说明

str_repeat(string $string, int $times): string

返回 string 重复 times 次后的结果。

参数

string

待操作的字符串。

times

string 被重复的次数。

times 必须大于等于 0。如果 times 被设置为 0,函数返回空字符串。

返回值

返回重复后的字符串。

范例

示例 #1 str_repeat() 范例

<?php
echo str_repeat("-=", 10);
?>

以上例程会输出:

-=-=-=-=-=-=-=-=-=-=

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top