function addArray($array, $indent) { $key = key($array); if (!isset($array[$key])) { return false; } if ($array[$key] === array()) { $array[$key] = ''; } $value = $array[$key]; // Unfolding inner array tree as defined in $this->_arrpath. //$_arr = $this->result; $_tree[0] = $_arr; $i = 1; $tempPath = Spyc::flatten($this->path); eval('$_arr = $this->result' . $tempPath . ';'); if ($this->_containsGroupAlias) { do { if (!isset($this->SavedGroups[$this->_containsGroupAlias])) { echo "Bad group name: {$this->_containsGroupAlias}."; break; } $groupPath = $this->SavedGroups[$this->_containsGroupAlias]; eval('$value = $this->result' . Spyc::flatten($groupPath) . ';'); } while (false); $this->_containsGroupAlias = false; } // Adding string or numeric key to the innermost level or $this->arr. if ($key) { $_arr[$key] = $value; } else { if (!is_array($_arr)) { $_arr = array($value); $key = 0; } else { $_arr[] = $value; end($_arr); $key = key($_arr); } } $this->path[$indent] = $key; eval('$this->result' . $tempPath . ' = $_arr;'); if ($this->_containsGroupAnchor) { $this->SavedGroups[$this->_containsGroupAnchor] = $this->path; $this->_containsGroupAnchor = false; } }
private function addArray($array, $indent) { if (count($array) > 1) { return $this->addArrayInline($array, $indent); } $key = key($array); if (!isset($array[$key])) { return false; } $value = $array[$key]; $tempPath = Spyc::flatten($this->path); // Unfolding inner array tree. $_arr = $this->result; foreach ($this->path as $k) { $_arr = $_arr[$k]; } if ($this->_containsGroupAlias) { do { if (!isset($this->SavedGroups[$this->_containsGroupAlias])) { echo "Bad group name: {$this->_containsGroupAlias}."; break; } $groupPath = $this->SavedGroups[$this->_containsGroupAlias]; $value = $this->result; foreach ($groupPath as $k) { $value = $value[$k]; } } while (false); $this->_containsGroupAlias = false; } // Adding string or numeric key to the innermost level or $this->arr. if ($key) { $_arr[$key] = $value; } else { if (!is_array($_arr)) { $_arr = array($value); $key = 0; } else { $_arr[] = $value; end($_arr); $key = key($_arr); } } $this->path[$indent] = $key; eval('$this->result' . $tempPath . ' = $_arr;'); if ($this->_containsGroupAnchor) { $this->SavedGroups[$this->_containsGroupAnchor] = $this->path; $this->_containsGroupAnchor = false; } }