PHP string str_repeat() Function

The str_repeat() is predefine function of PHP. It is used to repeat a string a specified number times. It returns input repeated multiple times.

Syntax:

ParameterDescriptionRequired/Optional
StringSpecify the string to repeat.Required
repeatSpecify the number of times for repeated.required

Example 1

Output:

Before using 'str_repeat()' function: ('.',13)
After using 'str_repeat()' function:..............

Example 2

Output:

Before using 'str_repeat()' function: ('-=',10)
After using 'str_repeat()' function:-=-=-=-=-=-=-=-=-=-=

Example 3

Output:

Before using 'str_repeat()' function: (' ??,10)
After using 'str_repeat()' function: ? ? ? ? ? ? ? ? ? ?;

Next TopicPHP String




Latest Courses