AppDividend
Latest Code Tutorials

PHP str_repeat() Function Example | str_repeat() Method In PHP

0

PHP str_repeat() Function Example | str_repeat() Method In PHP is today’s topic. The str_repeat() function repeats a string a specified number of times. A str_repeat() function is used to repeat the string, the specified number of times. The str_repeat() function is the built-in function in PHP and is used to create the new string by repeating the given string fixed number of times. 

PHP str_repeat() Function

The str_repeat() function takes the string and the integer as arguments and returns the new string which is generated by repeating a string passed as an argument by a number of times defined by an integer passed as an argument to this function.

See the following syntax.

str_repeat(string, repeat)

The string parameter is required and specifies a string to repeat.

The repeat parameter is required and it specifies the number of times the string will be repeated. Must be greater or equal to 0.

See the following code example.

<?php
  echo str_repeat("Eleven ", 11);

See the output.

➜  pro php Actor.php
Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven    
➜  pro

The function returns the new string made up by repeating the given string $string given number of times.

If the parameter $repeat passed to the function equals to 0, then the function returns an empty string.

Finally, PHP str_repeat() Function Example | str_repeat() Method In PHP is over.

Recommended Posts

PHP Join Example | PHP join() Function Tutorial

PHP Class Example | Basics Of Class In PHP Tutorial

PHP Implode Example | PHP implode() Function Tutorial

PHP str_replace Example | PHP str_replace() Function Tutorial

PHP Explode Function Example | PHP String Explode Tutorial

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.