← All built-ins / str_repeat()
str_repeat()
str_repeat(int $times, string $s): string
Parameters
| Name | Type | Description |
|---|---|---|
| $s | string | string to repeat |
| $n | int | how many times |
Return value
The string repeated $n times (empty when n <= 0).
Example
echo str_repeat("ab", 3), "
";
echo "[" . str_repeat("-", 5) . "]", "
";ababab [-----]