-
Notifications
You must be signed in to change notification settings - Fork 35
break
Umakant Patil edited this page Dec 11, 2013
·
2 revisions
{break} aborts the iteration. It may be inside {foreach}, {section}, {for} and {while} tags.
{$colors = [black=>'#000', blue=>'#00F', green=>'#0F0', red=>'#F00', white=>'#FFF']}
{foreach $colors as $color_name => $color_code}
{if $color_code@index == 3} {* abort iterating - show only first 3 items *}
{break}
{/if}
<span style="color:{$color_code}">{$color_name}</span>
{/foreach}
see also {break} in PHP Smarty documentation