array( "123" ), ... other params ...">

How to assign an array of values ​​to a parameter in Smarty?

In my php code.

$version_config = array( "list" => array( "123" ), ... other params ) $this->getView()->assign('version_config', $version_config); $this->getView()->assign('version_list', $version_config['list']); 

In my tpl code

 {assign var="version_list2" value="{$version_config.list}"} 

{$version_list2} is the string value of the Array, and {$version_list2} is the array. Do I need a few more operations to encode {$version_list2} into an array?

+5
source share
1 answer

Double quotes convert the $version_config.list array to the string "Array" just like "{$version_config['list']}" in PHP.

In addition, there is no need for curly braces in the value. Just pass the variable in the value parameter:

 {assign var="version_list2" value=$version_config.list} 
+4
source

Source: https://habr.com/ru/post/1262064/


All Articles