Forum Moderators: coopster
I am starting with multidimensional arrays and I can't seem to picture how to build and sort the following concept:
I have two variables (the zip and the distance in miles) I am pulling in a loop to build an array... how to go about sorting it out now by $miles?
Now what I am wondering is... is this correct syntax? Does it make any sense at all? I am really confused.
I have this example online but I can't seem to make it work:
if(($miles <= $distance)){
$data[$s] = array('zip' => $zip1[0], 'miles' => $miles);
$s++;
}
foreach ($data as $key => $row) {
$zip[$key] = $row['zip'];
$miles[$key] = $row['miles'];
}
$new = array_multisort($zip, SORT_DESC, $miles, SORT_ASC, $data);
print_r ($new);
Honestly I can't tell whether this is the right way to go as it's a first for me but I'd sure appreciate any tips/help!
Thanks :)
Andie