<?php
$array = Array
(
0 => Array
(
'name' => 'Nakiya',
'country' => 'USA',
'id' => 3,
),
1 => Array
(
'name' => 'Taylor',
'country' => 'UK',
'id' => 2,
),
2 => Array
(
'name' => 'Jack',
'country' => 'France',
'id' => 1,
)
);
array_multisort(array_map(function($element) {
return $element['id'];
}, $array), SORT_ASC, $array);
print_r($array);
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.16, 8.4.1 - 8.4.3
- Array
(
[0] => Array
(
[name] => Jack
[country] => France
[id] => 1
)
[1] => Array
(
[name] => Taylor
[country] => UK
[id] => 2
)
[2] => Array
(
[name] => Nakiya
[country] => USA
[id] => 3
)
)
preferences:
154.46 ms | 408 KiB | 5 Q