function D::setVal in QueryPath 6
Same name and namespace in other branches
- 7.3 qpa/qpa.phpunit.inc \D::setVal()
- 7.2 qpa/qpa.phpunit.inc \D::setVal()
Set the value of an item in a deeply nested array.
File
- qpa/
qpa.phpunit.inc, line 67
Class
Code
function setVal($key, $value) {
$t =& $this->arr;
$c = count($key);
for ($i = 0; $i < $c; ++$i) {
$part = $key[$i];
if ($c - 1 == $i) {
$t[$part] = $value;
}
else {
$t =& $t[$part];
}
}
return $t;
}