Computer >> Computer tutorials >  >> Programming >> PHP

str_repeat() function in PHP


The str_repeat() function is used to repeat a string.

Syntax

str_repeat(str_to_repeat, multiplier)

Parameters

  • str_to_repeat − The string to repeat.

  • multiplier − The number of times the string will be repeated. It must be greater than or equal to 0.

Return

The str_repeat() function returns the repeated string.

Example

The following is an example −

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

Output

The following is the output −

$$$$$$$$$$