Try this: ----------- $mi_boston = 645; //would be a calculation I guess $mi_ny = 886; //would be a calculation I guess $mi_chicago = 423; //would be a calculation I guess $mi_la = 1087; //would be a calculation I guess
$arr_places = array( '0' => array( 'City' => 'Boston', 'State' => 'Massachusett' , 'ZipCode' => '11111' , 'mileage' => $mi_boston , ), '1' => array( 'City' => 'New York', 'State' => 'New York' , 'ZipCode' => '11221', 'mileage' => $mi_ny , ), '2' => array( 'City' => 'Chicago', 'State' => 'Illinois' , 'ZipCode' => '33333', 'mileage' => $mi_chicago , ), '3' => array( 'City' => 'Los Angeles', 'State' => 'California' , 'ZipCode' => '99999', 'mileage' => $mi_la , ), ); //echo AS IS - just shows what it looks like before the mileage sort while ( list($key, $val) = each($arr_places) ) { echo "<p>$val[mileage] - $val[City], $val[State] $val[ZipCode]</p>\n"; } reset ( $arr_places ); echo "\n<p> </p>\n\n" //echo with a multisort //(Make the sort array out of the "mileage" while ( list($key, $val) = each($arr_places) ) { $sortarray[] = $val[mileage]; } reset ( $arr_places ); //probably not necessary but we'll do it anyway //sort ascending numerically by the "mileage" $sortarray array_multisort($arr_places,SORT_ASC,SORT_NUMERIC,$sortarray); while ( list($key, $val) = each($arr_places) ) { echo "<p>$val[mileage] - $val[City], $val[State] $val[ZipCode]</p>\n"; } Have fun... John --------------------- John Asendorf - [EMAIL PROTECTED] Web Applications Developer http://www.lcounty.com - NEW FEATURES ADDED DAILY! Licking County, Ohio, USA 740-349-3631 Nullum magnum ingenium sine mixtura dementiae fuit > -----Original Message----- > From: R.S. Herhuth [mailto:[EMAIL PROTECTED]] > Sent: Thursday, July 25, 2002 3:19 PM > To: Asendorf, John > Subject: Re: [PHP-WIN] Brain Twister > > > no, it is strictly read only.. > > I read that but I was having trouble visualizing how to put the info > into an array and sorting on just the distance. > > Ron > > "Asendorf, John" wrote: > > > > http://www.php.net/manual/en/function.asort.php > > > > http://www.php.net/manual/en/ref.array.php > > > > Is the information (non-mileage) going to be stored in a database? > > > > --------------------- > > John Asendorf - [EMAIL PROTECTED] > > Web Applications Developer > > http://www.lcounty.com - NEW FEATURES ADDED DAILY! > > Licking County, Ohio, USA > > 740-349-3631 > > Nullum magnum ingenium sine mixtura dementiae fuit > > > > > -----Original Message----- > > > From: R.S. Herhuth [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, July 25, 2002 3:10 PM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP-WIN] Brain Twister > > > > > > > > > > > > I have a series of offices (11 at the present time). Each > > > office has a > > > CITY STATE ZIPCODE and a MILEAGE. What I need to do is to > > > sort them by > > > mileage which is dynamically calculated earlier in the > script. I need > > > the offices to be stored in an array and sorted by the > MILEAGE after > > > which I will return them in the order that they have been sorted. > > > > > > How can I do this? > > > > > > Ron > > > > > > -- > > > PHP Windows Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php