3v4l.org

run code in 300+ PHP versions simultaneously
<?php $originalArray = array( 0 => array( 'dates' => '2021-10-20', 'hours' => array( 0 => array ( 0 => '07:30', 1 => '08:00', 2 => '08:30', 3 => '09:00', 4 => '09:30', 5 => '10:00', 6 => '10:30', 7 => '11:00', 8 => '11:30', 9 => '12:00', 10 => '12:30', 11 => '13:00' ), 1 => array ( 0 => '15:30', 1 => '16:00', 2 => '16:30', 3 => '17:00' ) ) ), 1 => array( 'dates' => '2021-10-19', 'hours' => array( 0 => array ( 0 => '07:30', 1 => '08:00', 2 => '08:30', 3 => '09:00', 4 => '09:30', 5 => '10:00', 6 => '10:30', 7 => '11:00', 8 => '11:30', 9 => '12:00', 10 => '12:30', 11 => '13:00' ), 1 => array ( 0 => '15:30', 1 => '16:00', 2 => '16:30', 3 => '17:00' ) ) ) ); $newArray = array(); foreach($originalArray as $originalArr){ foreach($originalArr['hours'] as $k=>$hours){ $newArray[$originalArr['dates']][$k]['dates'] = $originalArr['dates']; $newArray[$originalArr['dates']][$k]['hours'] = $hours; } } $newArray = array_values($newArray); print_r($newArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/PAppV
function name:  (null)
number of ops:  31
compiled vars:  !0 = $originalArray, !1 = $newArray, !2 = $originalArr, !3 = $hours, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   58     1        ASSIGN                                                   !1, <array>
   60     2      > FE_RESET_R                                       $7      !0, ->22
          3    > > FE_FETCH_R                                               $7, !2, ->22
   61     4    >   FETCH_DIM_R                                      ~8      !2, 'hours'
          5      > FE_RESET_R                                       $9      ~8, ->20
          6    > > FE_FETCH_R                                       ~10     $9, !3, ->20
          7    >   ASSIGN                                                   !4, ~10
   62     8        FETCH_DIM_R                                      ~12     !2, 'dates'
          9        FETCH_DIM_R                                      ~16     !2, 'dates'
         10        FETCH_DIM_W                                      $13     !1, ~12
         11        FETCH_DIM_W                                      $14     $13, !4
         12        ASSIGN_DIM                                               $14, 'dates'
         13        OP_DATA                                                  ~16
   63    14        FETCH_DIM_R                                      ~17     !2, 'dates'
         15        FETCH_DIM_W                                      $18     !1, ~17
         16        FETCH_DIM_W                                      $19     $18, !4
         17        ASSIGN_DIM                                               $19, 'hours'
         18        OP_DATA                                                  !3
   61    19      > JMP                                                      ->6
         20    >   FE_FREE                                                  $9
   60    21      > JMP                                                      ->3
         22    >   FE_FREE                                                  $7
   66    23        INIT_FCALL                                               'array_values'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $21     
         26        ASSIGN                                                   !1, $21
   68    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.11 ms | 1000 KiB | 15 Q