3v4l.org

run code in 300+ PHP versions simultaneously
<?php $datetimes = [ "items" => [ [ "id" => 1, "start_date" => "2019-09-26", "start_time" => "07:00:00", "end_date" => "2019-09-26", "end_time" => "09:00:00" ], [ "id" => 4, "start_date" => "2019-09-26", "start_time" => "12:00:00", "end_date" => "2019-09-26", "end_time" => "14:00:00" ], [ "id" => 9, "start_date" => "2019-09-26", "start_time" => "16:00:00", "end_date" => "2019-09-26", "end_time" => "17:00:00" ], [ "id" => 13, "start_date" => "2019-09-26", "start_time" => "19:00:00", "end_date" => "2019-09-26", "end_time" => "20:00:00" ], [ "id" => 2, "start_date" => "2019-09-27", "start_time" => "07:00:00", "end_date" => "2019-09-27", "end_time" => "08:00:00" ], [ "id" => 5, "start_date" => "2019-09-27", "start_time" => "12:00:00", "end_date" => "2019-09-27", "end_time" => "14:00:00" ], [ "id" => 10, "start_date" => "2019-09-27", "start_time" => "16:00:00", "end_date" => "2019-09-27", "end_time" => "18:00:00" ], [ "id" => 14, "start_date" => "2019-09-27", "start_time" => "19:00:00", "end_date" => "2019-09-27", "end_time" => "20:00:00" ], [ "id" => 3, "start_date" => "2019-09-28", "start_time" => "07:00:00", "end_date" => "2019-09-28", "end_time" => "10:00:00" ], [ "id" => 6, "start_date" => "2019-09-28", "start_time" => "12:00:00", "end_date" => "2019-09-28", "end_time" => "13:00:00" ], [ "id" => 11, "start_date" => "2019-09-28", "start_time" => "16:00:00", "end_date" => "2019-09-28", "end_time" => "17:00:00" ], [ "id" => 15, "start_date" => "2019-09-28", "start_time" => "19:00:00", "end_date" => "2019-09-28", "end_time" => "20:00:00" ] ] ]; $openinghours = []; function openinghours($times) { global $openinghours; $openinghours[$times["start_date"]][] = [ "start" => $times["start_time"], "end" => $times["end_time"] ]; } array_map("openinghours", $datetimes["items"]); var_dump($openinghours); foreach($openinghours as $date => $times) { echo "{$date} : {$times[0]["start"]} - " . end($times)["end"] . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 27
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/uhUeS
function name:  (null)
number of ops:  29
compiled vars:  !0 = $datetimes, !1 = $openinghours, !2 = $times, !3 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   92     1        ASSIGN                                                   !1, <array>
  105     2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 'openinghours'
          4        FETCH_DIM_R                                      ~6      !0, 'items'
          5        SEND_VAL                                                 ~6
          6        DO_ICALL                                                 
  107     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
  109    10      > FE_RESET_R                                       $9      !1, ->27
         11    > > FE_FETCH_R                                       ~10     $9, !2, ->27
         12    >   ASSIGN                                                   !3, ~10
  110    13        ROPE_INIT                                     4  ~15     !3
         14        ROPE_ADD                                      1  ~15     ~15, '+%3A+'
         15        FETCH_DIM_R                                      ~12     !2, 0
         16        FETCH_DIM_R                                      ~13     ~12, 'start'
         17        ROPE_ADD                                      2  ~15     ~15, ~13
         18        ROPE_END                                      3  ~14     ~15, '+-+'
         19        INIT_FCALL                                               'end'
         20        SEND_REF                                                 !2
         21        DO_ICALL                                         $17     
         22        FETCH_DIM_R                                      ~18     $17, 'end'
         23        CONCAT                                           ~19     ~14, ~18
         24        CONCAT                                           ~20     ~19, '%0A'
         25        ECHO                                                     ~20
  109    26      > JMP                                                      ->11
         27    >   FE_FREE                                                  $9
  111    28      > RETURN                                                   1

Function openinghours:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uhUeS
function name:  openinghours
number of ops:  11
compiled vars:  !0 = $times, !1 = $openinghours
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   RECV                                             !0      
   96     1        BIND_GLOBAL                                              !1, 'openinghours'
   98     2        FETCH_DIM_R                                      ~2      !0, 'start_date'
   99     3        FETCH_DIM_R                                      ~5      !0, 'start_time'
          4        INIT_ARRAY                                       ~6      ~5, 'start'
  100     5        FETCH_DIM_R                                      ~7      !0, 'end_time'
          6        ADD_ARRAY_ELEMENT                                ~6      ~7, 'end'
   98     7        FETCH_DIM_W                                      $3      !1, ~2
          8        ASSIGN_DIM                                               $3
  100     9        OP_DATA                                                  ~6
  103    10      > RETURN                                                   null

End of function openinghours

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
131.51 ms | 1017 KiB | 16 Q