Smarty - assign complete array
December 22nd, 2008
Smarty template engine provides variety of functions to replace variables in a html templates for example. assign, assign_by_ref. I would like to add one simple extension to assign function.
This function will take an associative array and will assign each key from this array to template.
1 2 3 4 5 6 | function replaceAll($array) { if(!$array) return; foreach($array as $key => $value) {$smarty->assign($key,$value);} } |
Hope this helps.