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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wat8i
function name:  (null)
number of ops:  11
compiled vars:  !0 = $datetimes, !1 = $openinghours
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                                      ~4      !0, 'items'
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
  107     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function openinghours:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Wat8i
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:
152.61 ms | 1011 KiB | 15 Q