3v4l.org

run code in 300+ PHP versions simultaneously
<?php $openTimeslots = ['02-09-2021' => [ '8:00-10:00', '16:00-19:00'], '03-09-2021' => [ '7:00-10:00', '16:15-19:00', '14:00-16:00', '13:00-14:15'], '04-09-2021' => [ '7:15-10:00', '15:15-18:15']]; $common = array_map(fn($timeRange) => explode('-', $timeRange), array_shift($openTimeslots)); foreach ($openTimeslots as $slots) { foreach ($slots as $slot) { [$start, $end] = explode('-', $slot); foreach ($common as [&$commonStart, &$commonEnd]) { if ($start >= $commonStart && $start < $commonEnd) { $commonStart = $start; } if ($end > $commonStart && $end <= $commonEnd) { $commonEnd = $end; } } } } var_export( array_map( fn($subarray) => implode('-', $subarray), $common ) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 49
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 49
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 47
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 47
Branch analysis from position: 14
2 jumps found. (Code = 125) Position 1 = 24, Position 2 = 45
Branch analysis from position: 24
2 jumps found. (Code = 126) Position 1 = 25, Position 2 = 45
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 38
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 44
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 44
Branch analysis from position: 42
Branch analysis from position: 38
Branch analysis from position: 36
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 45
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 47
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
filename:       /in/VADBi
function name:  (null)
number of ops:  59
compiled vars:  !0 = $openTimeslots, !1 = $common, !2 = $slots, !3 = $slot, !4 = $start, !5 = $end, !6 = $commonStart, !7 = $commonEnd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_FCALL                                               'array_map'
          2        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
          3        SEND_VAL                                                 ~9
          4        INIT_FCALL                                               'array_shift'
          5        SEND_REF                                                 !0
          6        DO_ICALL                                         $10     
          7        SEND_VAR                                                 $10
          8        DO_ICALL                                         $11     
          9        ASSIGN                                                   !1, $11
   10    10      > FE_RESET_R                                       $13     !0, ->49
         11    > > FE_FETCH_R                                               $13, !2, ->49
   11    12    > > FE_RESET_R                                       $14     !2, ->47
         13    > > FE_FETCH_R                                               $14, !3, ->47
   12    14    >   INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '-'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $15     
         18        FETCH_LIST_R                                     $16     $15, 0
         19        ASSIGN                                                   !4, $16
         20        FETCH_LIST_R                                     $18     $15, 1
         21        ASSIGN                                                   !5, $18
         22        FREE                                                     $15
   13    23      > FE_RESET_RW                                      $20     !1, ->45
         24    > > FE_FETCH_RW                                              $20, $21, ->45
         25    >   FETCH_LIST_W                                     $22     $21, 0
         26        MAKE_REF                                         $23     $22
         27        ASSIGN_REF                                               !6, $23
         28        FETCH_LIST_W                                     $25     $21, 1
         29        MAKE_REF                                         $26     $25
         30        ASSIGN_REF                                               !7, $26
         31        FREE                                                     $21
   14    32        IS_SMALLER_OR_EQUAL                              ~28     !6, !4
         33      > JMPZ_EX                                          ~28     ~28, ->36
         34    >   IS_SMALLER                                       ~29     !4, !7
         35        BOOL                                             ~28     ~29
         36    > > JMPZ                                                     ~28, ->38
   15    37    >   ASSIGN                                                   !6, !4
   17    38    >   IS_SMALLER                                       ~31     !6, !5
         39      > JMPZ_EX                                          ~31     ~31, ->42
         40    >   IS_SMALLER_OR_EQUAL                              ~32     !5, !7
         41        BOOL                                             ~31     ~32
         42    > > JMPZ                                                     ~31, ->44
   18    43    >   ASSIGN                                                   !7, !5
   13    44    > > JMP                                                      ->24
         45    >   FE_FREE                                                  $20
   11    46      > JMP                                                      ->13
         47    >   FE_FREE                                                  $14
   10    48      > JMP                                                      ->11
         49    >   FE_FREE                                                  $13
   23    50        INIT_FCALL                                               'var_export'
   24    51        INIT_FCALL                                               'array_map'
   25    52        DECLARE_LAMBDA_FUNCTION                          ~34     [1]
         53        SEND_VAL                                                 ~34
   26    54        SEND_VAR                                                 !1
   24    55        DO_ICALL                                         $35     
   26    56        SEND_VAR                                                 $35
   23    57        DO_ICALL                                                 
   28    58      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VADBi
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $timeRange
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '-'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VADBi
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $subarray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '-'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
210.16 ms | 1013 KiB | 18 Q