Do you need the values to be distributed in different arrays? I prefer information that belongs together to be grouped in code as well. This makes it easy to extract one point (and all of its information), add new points as well as sorting.
In this example it means $results
would look like this
[
location1,
start_date1,
etc...
],
[
location2,
start_date2,
etc...
],
[
location3,
start_date3,
etc...
]
Now you can sort them via usort()
and have values that belong together still grouped together.
I've created a small example (watch it work here)
$arr1 = array("foo", "ybar", "baz");
$arr2 = array("foo2", "ybar2", "baz2");
$arr3 = array("foo3", "ybar3", "baz3");
$results = array();
foreach ($arr1 as $key=>$value) {
$results[] = array(
'arr1' => $value,
'arr2' => $arr2[$key],
'arr3' => $arr3[$key],
);
}
function sortByArr1($a, $b) {
return strcmp($a['arr1'], $b['arr1']);
}
usort($results, "sortByArr1");
print "<pre>";
print_r($results);