PHP str_repeat() function is “used to create a new string by repeating a given string a fixed number of times.”
Syntax
str_repeat(string, repeat)
Parameters
- string: It is required and specifies a string to repeat.
- repeat: It is a required parameter specifying the number of times the string will be repeated. Must be greater or equal to 0.
Return value
This function returns a new string made up by repeating the given string several times.
Example: How to Use PHP str_repeat() function
<?php
echo str_repeat("Eleven ", 11);
Output
Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven Eleven
That’s it for this tutorial.

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.