<?php
$array = [
'id93294' => [
'Name' => 'Tom Anderson 2',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Matrix'
],
'id29349' => [
'Name' => 'Tom Anderson 1',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Matrix'
],
'id29348' => [
'Name' => 'Neo',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Real World'
],
'id29346' => [
'Name' => 'Neo',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'Zion'
],
'id29338' => [
'Name' => 'Tank',
'Birthday' => '04/20/1973',
'Hometown' => 'Zion',
'CurrentLocation' => 'Zion'
],
'id29342' => [
'Name' => 'Trinity',
'Birthday' => '08/09/1979',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Real World'
]
];
uasort($array, function($a, $b) {
return [strtotime($a['Birthday']), $a['Hometown'] !== $a['CurrentLocation'], $a['Name']]
<=>
[strtotime($b['Birthday']), $b['Hometown'] !== $b['CurrentLocation'], $b['Name']];
});
var_export($array);
- Output for 7.1.26 - 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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- array (
'id29338' =>
array (
'Name' => 'Tank',
'Birthday' => '04/20/1973',
'Hometown' => 'Zion',
'CurrentLocation' => 'Zion',
),
'id29349' =>
array (
'Name' => 'Tom Anderson 1',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Matrix',
),
'id93294' =>
array (
'Name' => 'Tom Anderson 2',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Matrix',
),
'id29348' =>
array (
'Name' => 'Neo',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Real World',
),
'id29346' =>
array (
'Name' => 'Neo',
'Birthday' => '03/17/1975',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'Zion',
),
'id29342' =>
array (
'Name' => 'Trinity',
'Birthday' => '08/09/1979',
'Hometown' => 'The Matrix',
'CurrentLocation' => 'The Real World',
),
)
preferences:
141.68 ms | 410 KiB | 5 Q