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"]][] = $times["start_time"]; $openinghours[$times["start_date"]][] = $times["end_time"]; sort($openinghours[$times["start_date"]]); } array_map("openinghours", $datetimes["items"]); var_dump($openinghours); foreach($openinghours as $date => $times) { echo "{$date} : {$times[0]} - " . end($times) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/jMvCP
function name:  (null)
number of ops:  27
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, ->25
         11    > > FE_FETCH_R                                       ~10     $9, !2, ->25
         12    >   ASSIGN                                                   !3, ~10
  110    13        ROPE_INIT                                     4  ~14     !3
         14        ROPE_ADD                                      1  ~14     ~14, '+%3A+'
         15        FETCH_DIM_R                                      ~12     !2, 0
         16        ROPE_ADD                                      2  ~14     ~14, ~12
         17        ROPE_END                                      3  ~13     ~14, '+-+'
         18        INIT_FCALL                                               'end'
         19        SEND_REF                                                 !2
         20        DO_ICALL                                         $16     
         21        CONCAT                                           ~17     ~13, $16
         22        CONCAT                                           ~18     ~17, '%0A'
         23        ECHO                                                     ~18
  109    24      > JMP                                                      ->11
         25    >   FE_FREE                                                  $9
  111    26      > RETURN                                                   1

Function openinghours:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jMvCP
function name:  openinghours
number of ops:  18
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'
          3        FETCH_DIM_R                                      ~5      !0, 'start_time'
          4        FETCH_DIM_W                                      $3      !1, ~2
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  ~5
   99     7        FETCH_DIM_R                                      ~6      !0, 'start_date'
          8        FETCH_DIM_R                                      ~9      !0, 'end_time'
          9        FETCH_DIM_W                                      $7      !1, ~6
         10        ASSIGN_DIM                                               $7
         11        OP_DATA                                                  ~9
  101    12        INIT_FCALL                                               'sort'
         13        FETCH_DIM_R                                      ~10     !0, 'start_date'
         14        FETCH_DIM_W                                      $11     !1, ~10
         15        SEND_REF                                                 $11
         16        DO_ICALL                                                 
  103    17      > RETURN                                                   null

End of function openinghours

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.83 ms | 1013 KiB | 17 Q