PHP str_repeat() Function

Example

Repeat the string "Shanghai " 5 times:

<?php
echo str_repeat("Shanghai",5);
?>

Run Instance

Definition and Usage

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

Syntax

str_repeat(string,repeat)
Parameter Description
string Required. Specifies the string to be repeated.
repeat Required. Specifies the number of times the string will be repeated. Must be greater than or equal to 0.

Technical Details

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