You are here

function Smarty::append_by_ref in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/smarty/Smarty.class.php \Smarty::append_by_ref()

appends values to template variables by reference

Parameters

string $tpl_var the template variable name:

mixed $value the referenced value to append:

File

includes/moodle/lib/smarty/Smarty.class.php, line 651

Class

Smarty
@package Smarty

Code

function append_by_ref($tpl_var, &$value, $merge = false) {
  if ($tpl_var != '' && isset($value)) {
    if (!@is_array($this->_tpl_vars[$tpl_var])) {
      settype($this->_tpl_vars[$tpl_var], 'array');
    }
    if ($merge && is_array($value)) {
      foreach ($value as $_key => $_val) {
        $this->_tpl_vars[$tpl_var][$_key] =& $value[$_key];
      }
    }
    else {
      $this->_tpl_vars[$tpl_var][] =& $value;
    }
  }
}