You are here

function QPACssEventHandler::setVal in QueryPath 6

Same name and namespace in other branches
  1. 7.3 qpa/qpa.classes.inc \QPACssEventHandler::setVal()
  2. 7.2 qpa/qpa.classes.inc \QPACssEventHandler::setVal()

Set the value of an item in a deeply nested array.

File

qpa/qpa.classes.inc, line 53
qpa.classes

Class

QPACssEventHandler
qpa.classes

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;
}