Repeat something n times without loop.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tylerdurden
Forum Commoner
Posts: 66
Joined: Mon Jul 28, 2003 11:52 am
Location: Austria

Repeat something n times without loop.

Post by tylerdurden »

Hi,

I'm trying to output a character n times, in my case I need it for indention:

$level = 1 -> output " "
$level = 2 -> output "  "
$level = 3 -> output "   "

and so on. Can I do it without constructing a loop?I think I read about a function to do this a while ago, can't seem to find it right now though.

Thanks,

Tyler
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

try this


<?php
echo str_repeat("&nbsp;", 10);
?>


will repeat &nbsp; 10 times

mark
tylerdurden
Forum Commoner
Posts: 66
Joined: Mon Jul 28, 2003 11:52 am
Location: Austria

Post by tylerdurden »

Thanks. That's it. So much for "not reading the f**king manual".
Post Reply