Reputation: 63
How can i get each value from the below array in smarty? I have :
{$categ|var_dump}
is
array(16) {
[0]=>
string(63) "
string(6) "MEN
string(29) "
string(0) ""
[4]=>
string(6) "
string(97) "
string(23) "Incaltaminte barbati
string(29) "
string(0) ""
[9]=>
string(6) "
string(72) "
string(10) "Pantofi
string(29) "
string(0) ""
[14]=>
string(6) "
string(5) "PRADA"
}
I have tried : {$categ[8]} ..{$categ[x]}
but its not returning nothing.
Have any ideea ?
Upvotes: 0
Views: 78
Reputation: 11808
You can use foreach to access element of array.You can use following example to learn that how to access array element.
$a = array(
"one" => 1,
"two" => 2,
"three" => 3,
"seventeen" => 17
);
foreach ($a as $k => $v) {
echo "\$a[$k] => $v.\n";
}
Here $k - will indicate to key of the array. $v- will indicate to value of particular key.
To know more please refer following link- http://php.net/manual/en/control-structures.foreach.php
Upvotes: 0
Reputation: 1165
Have you tried doing a foreach loop in Smarty?
<ul>
{foreach from=$myArray item=foo}
<li>{$foo}</li>
{/foreach}
</ul>
Upvotes: 1