PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How can I repeat a string variable several times?


When you want to tell someone how much you love them but can't be bothered to type it, how can you get PHP to take the strain for you?

Solution: use the str_repeat function of course! Just tell it what you want to repeat and how many times and it'll do the work for you, like so:

<?php
$bemine 
"I love you lots ";
echo 
"$bemine" str_repeat("and LOTS ",10);
?>


Giving us this touching declaration:

I love you lots and LOTS and LOTS and LOTS and LOTS and LOTS and LOTS and LOTS a
nd LOTS and LOTS and LOTS



Comment on this Question and Answer >>>

ASK A QUESTION

More strings PHP Questions

What is the usage of {} in strings?

How do I check if a string contains HTML?

What is the usage of { } in string handling in php?

What is the difference between join and implode in PHP?

How do I find the last occurrence of a character in a string?



Custom Search