/ Published in: PHP
/** * Traduce ricorsivamente un array multidimensionale * nella corrispondente struttura XML. * * @param mixed $array Array da tradurre * @return string */
Expand |
Embed | Plain Text
function _toXml($array) { foreach ($array as $key => $value) { // @FIXME se si tratta di un array indicizzato numericamente, si dovrebbe utilizzare come nodo la chiave padre $xml .= (!is_numeric($key) ? "<{$key}>" : "<item>") . _toXml($value) . (!is_numeric($key) ? "</{$key}>" : "</item>"); } else { } } return $xml; }
You need to login to post a comment.
