Last active
March 16, 2016 17:07
-
-
Save justenj/381fcc7c96229a6f0ee4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$xml = json_decode(json_encode(simplexml_load_file($data_file)), true); | |
$data = []; | |
foreach ($xml as $key => $many) { | |
foreach ($many as $one) { | |
foreach ($one as $item) { | |
$attributes = $item['@attributes']; | |
if (isset($attributes['id'])) { | |
$data[$key][$attributes['id']] = array_merge($attributes, $item); | |
} else { | |
$data[$key][] = array_merge($attributes, $item); | |
} | |
} | |
} | |
unset($xml[$key]); | |
} | |
unset($xml); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment