Çok boyutlu bir diziyi derinlemesine nasıl sıralayabilirim ve anahtarlarını nasıl tutabilirim?PHP array_multisort - anahtar değerleri nasıl tutmalı?
$array = [
'2' => [
'title' => 'Flower',
'order' => 3
],
'3' => [
'title' => 'Rock',
'order' => 1
],
'4' => [
'title' => 'Grass',
'order' => 2
]
];
foreach ($array as $key => $row) {
$items[$key] = $row['order'];
}
array_multisort($items, SORT_DESC, $array);
print_r($array);
sonucu:
Array
(
[0] => Array
(
[title] => Flower
[order] => 3
)
[1] => Array
(
[title] => Grass
[order] => 2
)
[2] => Array
(
[title] => Rock
[order] => 1
)
)
Sonra ben Ne:
Array
(
[2] => Array
(
[title] => Flower
[order] => 3
)
[4] => Array
(
[title] => Grass
[order] => 2
)
[3] => Array
(
[title] => Rock
[order] => 1
)
)
Herhangi bir fikir?
onay bu: [http://stackoverflow.com/questions/23740747/array-multisort-with-maintaining-numeric-index-association](http://stackoverflow.com/questions/23740747/array -multisort-ile-koruma-sayısal dizini-birliği) –