I'm working on a Hack project and I've come across a situation where I need to print $n
spaces. Here's how I'm currently doing it:
for ($i = 0; $i < $n; $i++) echo " ";
I'm wondering whether $n
calls to echo is the most efficient way to go about this? From a little bit of googling, I learned that generally, multiple calls to echo are faster than string concatenation and that Hack doesn't have a built in StringBuilder equivalent. Does my for loop achieve that maximum efficiency or is there something else I'm missing?
Thanks!