<?php
$xml = <<< XML
<?xml version="1.0"?>
<properties>
<property>
<propertyID>1</propertyID>
<price>200</price>
</property>
<property>
<propertyID>2</propertyID>
<price>100</price>
</property>
<property>
<propertyID>3</propertyID>
<price>300</price>
</property>
</properties>
XML;
$xml = simplexml_load_string($xml);
$properties = $xml->xpath("/properties/property");
usort($properties, function($a, $b) {
return $b->price - $a->price;
});
foreach($properties as $property) {
echo $property->propertyID . "<br>";
}
- Output for 5.6.0 - 5.6.24, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- 3<br>1<br>2<br>
preferences:
189.99 ms | 403 KiB | 228 Q