content_header = 'text/xml'; } /* */ function getSerializedArray($struct, $root = 1, $ind = ' ') { $n = "\n"; $r = ''; $is_flat = $this->isAssociativeArray($struct) ? 0 : 1; foreach ($struct as $k => $v) { $tag = $is_flat ? 'item' : preg_replace('/[\s]/s', '_', $k); $tag = preg_replace('/^.*([a-z0-9\-\_]+)$/Uis', '\\1', $tag); $r .= $n . $ind . '<' . $tag . '>' . (is_array($v) ? $this->getSerializedArray($v, 0, $ind . ' ') . $n . $ind : htmlspecialchars($v)) . ''; } if ($root) $r = $this->getHead() . $r . $this->getFooter(); return $r; } /* */ function getHead() { $n = "\n"; $r = ''; $r .= $n . ''; return $r; } function getFooter() { $n = "\n"; $r = $n . ''; return $r; } /* */ function isAssociativeArray($v) { foreach (array_keys($v) as $k => $val) { if ($k !== $val) return 1; } return 0; } /* */ }