Beniooo
7.10.2012, 17:39:53
Czesc, czy cos takiego jest mozliwe? Aby wczytac plik xml, i zamienic go na tablice assocjacyjna? I jak to zrobic jesli to mozliwe? ;]
KotWButach
7.10.2012, 17:48:55
function toArray($xml) {
$array = json_decode(json_encode($xml), TRUE);
if ( empty($value) ) $array[$key] = NULL; elseif ( is_array($value) ) $array[$key] = toArray
($value); }
return $array;
}
function toArray(SimpleXMLElement $xml) {
if ( $value instanceof SimpleXMLElement ) {
$array[$key] = empty($value) ?
NULL : toArray
($value); }
}
return $array;
}
http://php.net/manual/en/book.simplexml.php