Shekhar Joshi Shekhar Joshi - 1 year ago 83
PHP Question

access nested associative array in smarty template

I have a php array named

, which looks like this:

[consolidatedData] => Array
[0] => Array
[a_productidentification] => 5920
[avg_rating] => 4.0000
[no_reviews] => 2



and I am assigning it to a smarty variable like this:

self::$smarty->assign('cosolidatedReviews', $consolidatedReviewData);

Now, my question is how do I directly access
inside the .tpl?

Something like:


Answer Source

Use dots to access array items:


This is the same as the following in PHP:

echo $consolidatedReviews['consolidatedData'][0]['avg_rating'];

-> is for accessing object properties.