function Smarty::append in Quiz 6.5
Same name and namespace in other branches
- 6.6 includes/moodle/lib/smarty/Smarty.class.php \Smarty::append()
appends values to template variables
Parameters
array|string $tpl_var the template variable name(s):
mixed $value the value to append:
File
- includes/
moodle/ lib/ smarty/ Smarty.class.php, line 611
Class
- Smarty
- @package Smarty
Code
function append($tpl_var, $value = null, $merge = false) {
if (is_array($tpl_var)) {
// $tpl_var is an array, ignore $value
foreach ($tpl_var as $_key => $_val) {
if ($_key != '') {
if (!@is_array($this->_tpl_vars[$_key])) {
settype($this->_tpl_vars[$_key], 'array');
}
if ($merge && is_array($_val)) {
foreach ($_val as $_mkey => $_mval) {
$this->_tpl_vars[$_key][$_mkey] = $_mval;
}
}
else {
$this->_tpl_vars[$_key][] = $_val;
}
}
}
}
else {
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 $_mkey => $_mval) {
$this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
}
}
else {
$this->_tpl_vars[$tpl_var][] = $value;
}
}
}
}