An Entrepreneur, Coach, IT Consultant, Strategic Adviser, and a Traveler craving to explore and contribute to forming a better society.

Friday, August 21, 2009

Smarty foreach

No comments :
Smarty Foreach

The following is the smarty code snippet explaining how to use foreach in smarty

Code #1:


{foreach key=key item=item from=$arrayname}
{$key}: {$item}
{/foreach}


Code #2:




    {foreach from=$myArray key=k item=v}

  • {$k}: {$v}

  • {/foreach}

    • from => the array that needs to be processed
    • key => key value of the array (if it is an associative array)
    • key => value of the array[key] (if it is an associative array)

    Resources:
    http://smarty.net/manual/en/language.function.foreach.php

    No comments :