Skip to content

Instantly share code, notes, and snippets.

@zyphlar
Created May 26, 2012 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zyphlar/2792596 to your computer and use it in GitHub Desktop.
Save zyphlar/2792596 to your computer and use it in GitHub Desktop.
finding minimal value of a simplexml object in php
function find_min_rent($xml, $floorplanid) {
$min_rent = 999999; // a ridiculously high number
foreach($xml->xpath("/PhysicalProperty/Property/Unit[@FloorplanID='$floorplanid']") as $unit) {
if($unit->EffectiveRent['min'] < $min_rent) { // save this rent amount if it's the lowest so far
$min_rent = $unit->EffectiveRent['min'];
}
}
return $min_rent;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment