1.

How to repeat a string to a specific number of times in php?

Answer»

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)

Example

Here is an example demonstrating the same:
echo str_repeat("BIQ ", 2);

Output

BIQ BIQ



Discussion

No Comment Found