PHP str_repeat() function in PHP || PHP str_repeat() function
×


str_repeat() function in php

0 553

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:


Leave a Reply


Comments
    Waiting for your comments