1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| $sortVal = [
"test1" => [
"test2",
"test3",
"test4",
"test5",
],
"test2" => [
"test1",
"test3",
"test4",
"test5",
],
"test3" => [
"test1",
"test2",
"test4",
"test5",
],
"test4" => [
"test1",
"test2",
"test3",
"test5",
],
"test5" => [
"test1",
"test2",
"test3",
"test4",
],
];
foreach ($sortVal as $keys => $val) {
foreach ($val as $underKey => $underArray) {
for ($p = 0; $p <= 4; $p++) {
if (!array_key_exists($p, $data)) {
$data[$p] = [];
}
if (!array_key_exists($keys, $data[$p]) && !in_array($underArray, $data[$p])) {
$data[$p][$keys] = $underArray;
unset($sortVal[$keys][$underKey]);
break;
}
}
}
} |
Partager