String Functions

PHP str_repeat() Function

Topic: PHP String ReferencePrev|Next


The str_repeat() function repeats a string specified number of times.

The following table summarizes the technical details of this function.

Return Value: Returns the repeated string.
Version: PHP 4+


The basic syntax of the str_repeat() function is given with:

str_repeat(string, multiplier);

The following example shows the str_repeat() function in action.

// Sample string
$str = "Ha ";

// Repeating the string
echo str_repeat($str, 10);


The str_repeat() function accepts the following parameters.

Parameter Description
string Required. Specifies the string to repeat.
multiplier Required. Specifies the number of times the should be repeated. It must be greater than or equal to 0. If it is set to 0, the function will return an empty string.
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties