Jump to content

Loops

Standard PHP loop types are supported as HTML logic tags.

 

Foreach

{{foreach [expression]}}
	...
{{endforeach}}

Expression is anything PHP would support in a loop. The variables the loop defines are available within the body of the loop:

<ul>
  {{foreach $arrayOfItems as $id => $item}}
      <li>{$id}: {$item}</li>
  {{endforeach}}
</ul>

 

For

{{for [expression]}}
	...
{{endfor}}

For example:

<ul>
	{{for $i = 0; $i < count( $arrayOfItems ); $i++}}
		<li>{$i}</li>
	{{endfor}}
</ul>

 

Breaking and continuing

If you need to break or continue a loop, you can use the relevant PHP statement to do so. For example, using break:

{{foreach $arrayOfItems as $id => $item}}
	{{if $id > 15}}
		{{break;}}
	{{endif}}
{{endforeach}}

 


  Report Guide


×
×
  • Create New...