Sorting an array.
| From: | Mike Mike | Date: | Thu, 18 Apr 2002 13:51:13 +0000 |
| Subject: | Sorting an array. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-93533@lists.php.net to get a copy of this message | ||
Hello,
Here's what i'm working with.
I'm figuring the distance between to points based on
latitude and longitude.
while ($row = mysql_fetch_array($result))
{
//calculate distance between the two cities.
$Lat2 = $row["Latitude"];
$Lon2 = $row["Longitude"];
$x = 69.1 * ($Lat2 - $Lat1);
$y = 53 * ($Lon2 - $Lon1);
$Distance = sqrt($x * $x + $y * $y);
$Distance = ceil($Distance);
if ($Distance < 100){
echo $row["CompanyName"]."<br>";
echo $row["Address"]."<br>";
echo $row["City"]."<br>";
echo $row["State"]."<br>";
echo $row["ZipCode"]."<br>";
echo $row["PhoneNumber"]."<br>";
echo $row["FaxNumber"]."<br>";
echo "Approximant Distance = $Distance
Miles<br><br>";
}
}
Here is where my question comes to play. How do I
sort the $Distance so that 4 Miles will come up first
10 second 30 third ext..
I have tried useing sort() function but it doesn't
work quite the way I want it to.
Thanks for your help
--Mike
__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/