In ruby on Rails, you have the option to create cleaner and well formated output:
<div>
<%= 3.times do -%>
<%= "Hello World" -%>
<%= end -%>
</div>
and the output will be:
<div>
Hello World
Hello World
Hello World
</div>
But when i do the same thing in php:
<div>
<?php for ($i =0; $ < 3;$i++): ?>
<?php echo "Hello World" ?>
<?php endfor; ?>
</div>
I get something like this:
<div> Hello World
Hello World
Hello World
</div>
is there something like rubys “-%>” in php that help me acheive the same thing?
Keep in mind that PHP is a preprocessor, so basically it just appends some stuff to your files. This means that to achieve the correct “style” or “cleanness” in your file you will need to add newlines etc. to ( randomly ) generated stuff.
for instance for every loop add \n to the end of the string so it will print it on a new line of the file. If you want a tab you could do \t and so forth