Forum Moderators: coopster
I have a little need that is stumping me, I'm hoping someone can help.
I have a group of ZIP codes (zipcodesB) that are stored in an array, as well as a script that will tell me how far each of them is from ZipcodeA.
I want to write them back into a Multi-dimensional array with zipcode & distance like so:
$zips=array(array(44720,0),array(44721,0),array(44735,3), etc.)
How would I go about writing each one to screen (or perform some other function) based on distance from closest to farthest?
any help would be appreciated.
R
i.e.:
function compareByDistance( $z1, $z2 ) {
//assuming zip[0] == code && zip[1] == distance
return ( $z1[1] < $z2[1] ) ? -1 : 1;
}usort( $zips, "compareByDistance" );
foreach( $zips as $zip ) {
echo ' ... ';
}