So I have an XML file that I am trying to loop through in order, according to the attribute, \"order\".
Here is an example:
This should give you what you want:
$string = <<
EOS;
$xml = simplexml_load_string($string);
$trees = $xml->xpath('/page/talentTrees/tree');
function sort_trees($t1, $t2) {
return strcmp($t1['order'], $t2['order']);
}
usort($trees, 'sort_trees');
var_dump($trees);
$trees are now sorted by the order attribute.