Computing Magazine

Iterate Array Contents in Smarty Templates

Posted on the 04 May 2012 by Akahgy


Iterate an Array passed as a variable in a Smarty template


The equivalent of foreach() clause in PHP translates as section in Smarty templates, as following:

{section name=arrayID loop=$theArray}

   <input type=checkbox” name=”{$theArray[arrayID ]}”


The code above outputs a sequence of check boxes named with the value of each element of the Array.

Back to Featured Articles on Logo Paperblog