3v4l.org

run code in 500+ PHP versions simultaneously
<?php $dataArray = [ 0 => "AAAAA 2023 01 25 01:04:00 ID:20fjrjeZZ", 1 => "AAAAA 2023 01 25 01:18:08 ID:13454B43A", 2 => "AAAAA 2023 01 25 02:00:02 ID:18f5hjeWe", 3 => "AAAAA 2023 01 25 04:10:13 ID:13454B43A", 4 => "BBBBB 2023 01 25 01:44:10 ID:Xj74320fj", 5 => "BBBBB 2023 01 25 07:08:58 ID:13454B43A", 6 => "BBBBB 2023 01 25 08:40:52 ID:Ftzkk800Y", 7 => "BBBBB 2023 01 25 14:10:13 ID:18f5hjeWe" ]; foreach ($dataArray as $row) { [$group, $y, $m, $d, $t, $id] = explode(' ', $row); $result[$group]['user'][$id][] = $t; $result[$group]['first'] ??= $t; $result[$group]['last'] = $t; $result[$group]['totaluser'] = count($result[$group]['user']); $result[$group]['totalAccess'] = ($result[$group]['totalAccess'] ?? 0) + 1; } var_export($result);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
array ( 'AAAAA' => array ( 'user' => array ( 'ID:20fjrjeZZ' => array ( 0 => '01:04:00', ), 'ID:13454B43A' => array ( 0 => '01:18:08', 1 => '04:10:13', ), 'ID:18f5hjeWe' => array ( 0 => '02:00:02', ), ), 'first' => '01:04:00', 'last' => '04:10:13', 'totaluser' => 3, 'totalAccess' => 4, ), 'BBBBB' => array ( 'user' => array ( 'ID:Xj74320fj' => array ( 0 => '01:44:10', ), 'ID:13454B43A' => array ( 0 => '07:08:58', ), 'ID:Ftzkk800Y' => array ( 0 => '08:40:52', ), 'ID:18f5hjeWe' => array ( 0 => '14:10:13', ), ), 'first' => '01:44:10', 'last' => '14:10:13', 'totaluser' => 4, 'totalAccess' => 4, ), )

preferences:
77.41 ms | 1241 KiB | 4 Q