I'm trying to sort following array:
$myArray = array(
"ID" => array(
0,
5,
8,
12,
15
),
"date" => array(
1484391600,
1483910300,
1484920000,
1482393630,
1484391600
),
"name" => array(
"Pete",
"Max",
"Tom",
"June",
"Arend"
),
);
I want to be able to choose which subarray is sorted and in which way (numeric / string) and order (DESC / ASC). All the other subarrays should be sorted accordingly.
Here is some code that worked at first, but when the subarray to sort contained an empty string, it failed: All subarrays where sorted differently.
$sortCatArray = $myArray['name'];
foreach($myArray as $category => $value){
$keepOrigin = $sortCatArray;
array_multisort($keepOrigin, SORT_DESC, SORT_STRING, $myArray[$category]);
}
var_dump($myArray);
Can someone point out what I'm doing wrong.
Also I don't want to rearrange the arrays to match the other sorting solutions as I need the values in the given format.