str_repeat() function in php
0 2159
PHP str_repeat() function is used to repeat a string to a particular number of times given by the user. It is an inbuilt function of PHP.
Syntax:
str_repeat($string, $repeat);
here,
- $string is a PHP string.
- $repeat represents the number of repentance of the string.
Example:
<?php $str="hello "; $modify_str=str_repeat($str,5); echo "Original string is : <strong>$str</strong><br>"; echo "Repeated string is : <strong>$modify_str</strong>"; ?>
Output:
Share:
Comments
Waiting for your comments