Reputation: 533
Array
(
[0] => Array
(
[product_id] => 49
[thumb] => http://192.168.0.101/user1/OPC_Fabish3.0/upload/image/cache/catalog/demo/banners/Productimage-278x355.jpg
[rollover_thumb] => http://192.168.0.101/user1/OPC_Fabish3.0/upload/image/cache/catalog/demo/banners/Productimage-278x355.jpg
[name] => tulip lamp family
[description] => Samsung Galaxy Tab 10.1, is the world’s thinnest tablet, measuring 8.6 mm thickness, running w..
[price] => $241.99
[special] =>
[tax] => $199.99
[rating] => 0
[href] => http://192.168.0.101/user1/OPC_Fabish3.0/upload/index.php?route=product/product&product_id=49
[model] => SAM1
)
)
This is my products
array in PHP
.
In twig I am fetching the values using the following code:
{% for j in 0..(products|length) %}
<a href="{{ products.j[href] }}"></a>
{% endfor %}
However I am not getting any result.
Upvotes: 1
Views: 104
Reputation: 54796
I suppose it is:
<a href="{{ products[j]['href'] }}"></a>
// or
<a href="{{ products[j].href }}"></a>
Or simplier:
{% for product in products %}
<a href="{{ product.href }}"></a>
{% endfor %}
Upvotes: 2