How to repeat a string to a specific number of times in php?
In PHP, the str_repeat()
function, which is inbuilt is used to repeat a string for a specific number of times. This str_repeat() function creates new strings by repeating the given string ‘n’ number of times as specified.
Here is the syntax of the str_repeat() function: str_repeat(string, repeat)
BY Best Interview Question ON 20 Apr 2020
Example
Here is an example demonstrating the same:
echo str_repeat("BIQ ", 2);
Output
BIQ BIQ