This post answered this question but I didn't understand the answers very well
I have an array contains dates,
I want to sort column date_res
(results date) by the closest to today not the greatest or the smallest
my array may help you
<?php
$today = date('Y-m-d');
$arr = array(
[
'id' => '1',
'date' => '2020-03-27',
'date_end' => '2020-05-02 17:00',
'date_res' => '2020-06-02'
],
[
'id' => '2',
'date' => '2020-04-27',
'date_end' => '2020-06-02 17:00',
'date_res' => '2020-08-02'
],
[
'id' => '3',
'date' => '2020-06-27',
'date_end' => '2020-07-02 17:00',
'date_res' => '2020-08-02'
],
[
'id' => '4',
'date' => '2021-01-01',
'date_end' => '2021-02-01 17:00',
'date_res' => '2021-03-01'
],
[
'id' => '5',
'date' => '2021-02-01',
'date_end' => '2021-03-01 17:00',
'date_res' => '2021-04-01'
],
[
'id' => '6',
'date' => '2021-05-01',
'date_end' => '2021-06-01 17:00',
'date_res' => '2021-08-01'
],
[
'id' => '7',
'date' => '2021-02-06',
'date_end' => '2021-01-29 17:00',
'date_res' => '2021-01-29'
],
[
'id' => '9',
'date' => '2021-04-27',
'date_end' => '2021-05-03 17:00',
'date_res' => '2021-05-03'
],
[
'id' => '10',
'date' => '2021-02-01',
'date_end' => '2021-02-06 17:00',
'date_res' => '2021-05-03'
],
[
'id' => '11',
'date' => '2021-02-02',
'date_end' => '2021-02-07 17:00',
'date_res' => '2021-05-05'
],
[
'id' => '12',
'date' => '2021-03-27',
'date_end' => '2021-02-07 17:00',
'date_res' => '2021-06-02'
]);
?>