HOW TO USE THE str_repeat() FUNCTION IN PHP
The str_repeat() function takes a string and repeats it to the specified number of times. It takes two parameters: the string to perform the repeat action on and the number of times to repeat.
Example 1:
$string="John";
$newstring=str_repeat($string,3);
echo $newstring;
The above will output: JohnJohnJohn
Example 2:
$string="Mary lives here";
$newstring=str_repeat($string,2);
echo $newstring;
The above will output:
Mary lives hereMary lives here
|