flexy:foreach="variable,key,value" -- creates a PHP foreach loop using a html attribute
Description
creates a foreach loop, around the tag and close tag.
Parameter
string variable -
relates to $object->variable
string key -
creates a variable 'key' in the current scope.
string value - optionally
creates a variable 'value' in the current scope. (as in $key=>$value)
Example
Example 31-2. Foreach in template <table>
<tr flexy:foreach="a,k,v">
<td>k is {k}, and v is {v}</td>
</tr>
</table>
<table>
<tr flexy:foreach="b,v">
<td>v is {v}</td>
</tr>
</table> |
|
Example 31-3. Compiled template <table>
<?php if (is_array($t->a)) foreach($t->a as $k => $v) { ?><tr>
<td>k is <?php echo htmlspecialchars($t->k); ?>, and v is <?php echo htmlspecialchars($t->v); ?></td>
</tr><?php } ?>
</table>
<table>
<?php if (is_array($t->b)) foreach($t->b as $v) { ?><tr>
<td>v is <?php echo htmlspecialchars($t->v); ?></td>
</tr><?php } ?>
</table> |
|