str_repeat() Function in PHP 8.2, PHP 8.3 & PHP 8.4


The str_repeat() function in PHP 8, PHP 8.1, PHP 8.2, PHP 8.3 & PHP 8.4 repeats a string a specified number of times.Syntax
<?phpstr_repeat(string $string, int $times): string?>

Parameters

$string - The string to be repeated.$times - Number of times the string should be repeated (must be ? 0)Return Value.Returns the repeated string. If $times is 0, an empty string is returned.Examples
<?phpecho str_repeat("-=", 10);// Output: -=-=-=-=-=-=-=-=-=-=echo str_repeat("Hello ", 3);// Output: Hello Hello Hello echo str_repeat("PHP", 0);// Output: (empty string)?>