str_repeat

文字列を反復する

説明

string str_repeat(string $string, int $times)

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

パラメータ

string

繰り返す文字列。

times

string を繰り返す回数。

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

戻り値

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

例1 str_repeat の例

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

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

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

参考

  • for
  • str_pad
  • substr_count