[Solved] How to pass array from php to javascript using smarty 3? [closed]


In php:

$names = ['jim', 'lucy'];
$smarty->assign('names', $names);

In javascript,

var arr = {$names|json_encode};

Notice:
If you changed your smarty default_modifiers to array('escape:"html"'), use

var arr = {$names|json_encode nofilter};

to make everything work.

Good luck.

solved How to pass array from php to javascript using smarty 3? [closed]