array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.str-repeat.php', 1 => 'str_repeat', ), 'up' => array ( 0 => 'ref.strings.php', 1 => '字符串 函数', ), 'prev' => array ( 0 => 'function.str-pad.php', 1 => 'str_pad', ), 'next' => array ( 0 => 'function.str-replace.php', 1 => 'str_replace', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/strings/functions/str-repeat.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
str_repeat — 重复一个字符串
string
待操作的字符串。
times
string
被重复的次数。
times
必须大于等于 0。如果 times
被设置为 0,函数返回空字符串。
返回重复后的字符串。
示例 #1 str_repeat() 示例
<?php
echo str_repeat("-=", 10);
?>
以上示例会输出:
-=-=-=-=-=-=-=-=-=-=