Page 1 of 1

Repeat something n times without loop.

Posted: Fri Aug 29, 2003 5:23 am
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

Posted: Fri Aug 29, 2003 5:42 am
by JayBird
try this


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


will repeat &nbsp; 10 times

mark

Posted: Fri Aug 29, 2003 5:54 am
by tylerdurden
Thanks. That's it. So much for "not reading the f**king manual".