← All built-ins / str_repeat()

str_repeat()

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

Parameters

NameTypeDescription
$sstringstring to repeat
$ninthow many times

Return value

The string repeated $n times (empty when n <= 0).

Example

echo str_repeat("ab", 3), "
";
echo "[" . str_repeat("-", 5) . "]", "
";
ababab
[-----]

See also

implode()str_pad()