Course Recommendation:

PHP str_repeat() Function

Example

Repeat the string "Shanghai " 5 times:
<?php
echo str_repeat("Shanghai",5);

?>

Running Example

Definition and Usage

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

Syntaxstringstr_repeat(repeat,
) 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+