My array as bellow :
$data = [
'0' => [
'depart' => '2021-02-09 10:50:00',
'arrival' => '2021-02-09 13:10:00',
],
'1' => [
'depart' => '2021-02-09 14:50:00',
'arrival' => '2021-02-09 15:30:00',
],
'2' => [
'depart' => '2021-02-09 18:20:00',
'arrival' => '2021-02-09 19:40:00',
]
];
From above array, I want to calculate different time to be :
0 = calculate different time between [0]['arrival'] and [1]['depart']
1 = calculate different time between [1]['arrival'] and [2]['depart']
My code :
$diff_time = [];
foreach ($data as $d => $dta) {
$diff_time[$d] = timeDifference($dta['arrival'], $dta['depart']);
}
Thank you for assistance.