I have an array, that I construct within a mysql fetch array loop. This array contains values such as:
Array ( [0] => 1 Hour: 1.6
[1] => 2 Hour: 2.3
[2] => 3 Hour: 2.8
[3] => 4 Hour: 3.7
[4] => 8 Hour: 7.0 )
Array ( [0] => 2 Hour: 1.5
[1] => 4 Hour: 2.9
[2] => 8 Hour: 3.8
[3] => 12 Hour: 5.0
[4] => 24 Hour: 8.9 )
What is the best way to sort the cheapest prices for a given duration, so if I select one hour, I still get the second two hours returned as the cheapest.
To further complicate this the array may sometimes contain:
Array ( [0] => Free )
I was thinking creating a class with a getPrice(duration) function, within my loop I would declare a new instance of this and add a pointer to a global array, before finally looping through each item in this global array to find the cheapest. Is this solution viable? or is there a better alternative?
while($row = mysql_fetch_array($results))
{
$price = explode(';', $row['price']);
print_r($price);
}
Thanks