function XMLArrayInstance::setArrValue in Campaign Monitor 5.2
1 call to XMLArrayInstance::setArrValue()
- XMLArrayInstance::end in lib/CMBase.php
File
- lib/CMBase.php, line 650
Class
- XMLArrayInstance
- XMLArrayInstance, xml2array() and array2xml() will be used to convert data
between XML and Array. We're using a class because that is the only way we can
safely use xml_parse() and other related functions (the alternative is to use
$GLOBALS to…
Code
function setArrValue($data) {
$ptr =& $this->array;
$depth = $this->stack_sz - 1;
$sep = '';
$partial = '';
for ($i = $this->rootStart; $i < $this->stack_sz; $i++) {
$key = $this->stack[$i];
$partial .= $sep . $key;
$sep = '/';
$_c = $this->stack_count[$this->stack_prefix . $partial];
if (!isset($ptr[$key])) {
if ($i == $depth) {
$ptr[$key] = $data;
}
else {
$ptr[$key] = array();
}
$ptr =& $ptr[$key];
}
elseif ($i < $depth) {
if ($_c > 0) {
if (!isset($ptr[$key][0])) {
$tmp = $ptr[$key];
$ptr[$key] = array(
$tmp,
);
}
if (!isset($ptr[$key][$_c])) {
$ptr[$key][$_c] = array();
}
$ptr =& $ptr[$key][$_c];
}
else {
$ptr =& $ptr[$key];
}
}
elseif ($i == $depth) {
if (!is_array($ptr[$key])) {
$tmp = $ptr[$key];
$ptr[$key] = array(
$tmp,
);
}
elseif (!isset($ptr[$key][0])) {
$tmp = $ptr[$key];
$ptr[$key] = array(
$tmp,
);
}
$ptr[$key][] = $data;
$ptr =& $ptr[$key];
}
}
}