PHP 字符串 str_repeat() 函数

2024 年 9 月 4 日 | 阅读 1 分钟

str_repeat() 是 PHP 的预定义函数。它用于将一个字符串重复指定的次数。它返回输入字符串重复多次的结果。

语法

参数描述必需/可选
String指定要重复的字符串。必需
repeat指定重复的次数。必需

示例 1

输出

Before using 'str_repeat()' function: ('.',13)
After using 'str_repeat()' function:..............

示例 2

输出

Before using 'str_repeat()' function: ('-=',10)
After using 'str_repeat()' function:-=-=-=-=-=-=-=-=-=-=

示例 3

输出

Before using 'str_repeat()' function: (' ??,10)
After using 'str_repeat()' function: ? ? ? ? ? ? ? ? ? ?;

下一主题PHP 字符串