# Re: [PHP] Sorting an array.

```Perhaps you could store \$row in an array of arrays; store only \$row within
100 miles. Add another field, Distance, to each row that holds the
calculated distance.  Then, after creating the array, sort the final array
by Distance.
----- Original Message -----
From: Mike Mike <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 18, 2002 8:51 AM
Subject: [PHP] Sorting an array.```
```

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))
{
file://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["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/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

```