Reputation: 11
My smarty {brands}
has returns this array:
array (size=2)
0 =>
array (size=3)
'id' => string '98' (length=2)
'name' => string 'Adidas' (length=6)
1 =>
array (size=3)
'id' => string '168' (length=3)
'name' => string 'Agisko' (length=6)
I need, that this views all name
from array. How Can I write this is in smarty?
<ul>
{foreach $brands as $brand}
<li>{$brands|var_dump}</li>
{/foreach}
</ul>
Upvotes: 0
Views: 33
Reputation: 3707
Associative array values can be accessed as you would in PHP code, or using dot notation:
<ul>
{foreach $brands as $brand}
<li>{$brand['name']}</li>
{/foreach}
</ul>
<ul>
{foreach $brands as $brand}
<li>{$brand.name}</li>
{/foreach}
</ul>
Upvotes: 1