this question has answer here:
- sorting xml simplexml/xpath? 3 answers
i having little trouble xml feed (atom). running each loop return prices using simple xml , converting them arrays works fine below :-
foreach ($dc->departures->departure $price) { $lowest = $price->prices->price[5]->asxml(); $lowestval = array($lowest); print_r($lowestval); }
which returning :-
array ( [0] => 2289 ) array ( [0] => 2207 ) array ( [0] => 2369 ) array ( [0] => 2229 )
my goal return lowest price, can display prices from: area. understand need use min()
function, works 1 array several values. i've tried array_merge doesn't seem work , returns same above. php newbie there maybe obvious. kick in correct direction appreciated.
try this. working fine
<?php foreach ($dc->departures->departure $price) { $lowest = $price->prices->price[5]->asxml(); $lowestval[] = $lowest; } $min = min($lowestval); echo $index = array_search($min, $array); ?>
Comments
Post a Comment