« str_pad
str_replace »

str_repeat

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

str_repeat — 文字列を反復する

説明

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

string を times 回繰り返した文字列を返します。

パラメータ

string

繰り返す文字列。

times

string を繰り返す回数。

times は 0 以上でなければなりません。 times が 0 に設定された場合、この関数は空文字列を返します。

戻り値

繰り返した文字列を返します。

例

例1 str_repeat() の例

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

上の例の出力は以下となります。

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

参考

関連キーワード:
repeat   times   反復   回数   replace   以上   参考   固定   substr   count   出現
関連する関数・ページ:
countable.count   function.posix-times   evtimer.set   function.mb-substr-count   class.evtimer   parle.pattern.matching