Foreach does not return all values

Solution 1:

If we consider your data won't change, and you have 3 entries to get, you can use array_chunk:

$result = [];
foreach ($data as $day => $times) {
    $timesChunked = array_chunk($times, 3);
    
    foreach ($timesChunked as $time) {
        $result[$day] []= [
            'open' => $time[0],
            'close' => $time[1],
            'code' => $time[2],
        ];
    }
}

But your problem was logical, you don't change the key in your loop, of course your array will have only the last elements. Reread your code, and try to understand why.