I want to create a sortable list that looks something like
- $VAR1[0], $VAR2[0]...
- $VAR1[1], $VAR2[1]...
The data comes from multiple same structured xml files:
$xmlfile="
<Level1>
<Level2>
<Level2Item VAR1="1" VAR2="2" ... />
<Level2Item VAR1="4" VAR2="5" ... />
<Level2Item VAR1="7" VAR2="8" ... />
</Level2>
</Level1>";
//Extract each item
$xml = new SimpleXMLElement($xmlfile);
foreach ($xml->Level2[0] as $result) {
array_push($VAR1Array, $result['VAR1']);
array_push($VAR2Array, $result['VAR2']);
//... etc etc
}
//sort
//$sortedArray = sort($VAR1Array);
Output
Array(
[0] => SimpleXMLElement Object([0] => 1)
[1] => SimpleXMLElement Object([0] => 4)
[2] => SimpleXMLElement Object([0] => 7)
)
From this XML structure, what's the best way of storing the data in one array? I want to be able to gather all the data in one array so I can sort it by one or 2 VARs and display the results.