The php str_repeat() function helps to repeat the string the specified number of times.
The str_repeat() function generates a new string by iterating over the given string a predetermined number of times.
PHP has a built-in function called str_repeat()
that repeats a string a specified number of times. The str_repeat()
function requires two arguments: a string and an integer. It produces a new string that is created by iterating through a string supplied as an input as many times as the integer passed as an argument to this function allows.
str_repeat(string, repeat)
Whereas:
– string : The string parameter is mandatory, and it specifies a repeating string.
– repeat : It specifies the number of times the string will be repeated. The value must be greater or equal to 0.
If the function’s $repeat
parameter is set to 0
, the function returns an empty string.
Let’s repeat a string in php.
echo str_repeat("phpflow ", 4);
Output:
phpflow phpflow phpflow phpflow
The function returns a new string created by iterating through the specified string $string.
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More