3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * step 1: create benchmark array * containing all consecutive dates from $start */ $start = '2019-10-27 16:30:00'; $days = 14; // total number of days (including $start) $dateObj = new DateTimeImmutable($start); $benchmarkDates[] = $dateObj->format('Y-m-d H:i:s'); // store the first bench date for ($i = 1; $i < $days; $i++) { $period = 'P' . $i . 'D'; $interval = new DateInterval($period); $dateObj0 = $dateObj->add($interval); $benchmarkDates[] = $dateObj0->format('Y-m-d H:i:s'); // store the next bench date } /* * create dummy array mimicking the OP's presented structure * create date gaps */ $start = '2019-10-27 16:30:00'; $days = 14; // total number of days (including $start) $dateObj = new DateTimeImmutable($start); $subject[0][] = ['datum' => $dateObj]; // store the first object for ($i = 2; $i < $days; $i += 2) { $period = 'P' . $i . 'D'; $interval = new DateInterval($period); $dateObj0 = $dateObj->add($interval); $subject[$i / 2][] = ['datum' => $dateObj0]; // store subsequent objects } /* step 2: get dates from subject array ($subject). */ foreach ($subject as $key => $value) { foreach ($value as $key => $value) { $subjectDates[] = $value['datum']->format('Y-m-d H:i:s'); // store dates } } /* * step 3: find / store missing dates * check subject against benchmark */ foreach($benchmarkDates as $key => $value) { if(!in_array($value, $subjectDates)) { $missingDates[] = $value; } } echo 'benchmark array:' . "\r\n"; print_r($benchmarkDates); echo 'subject array:' . "\r\n";; print_r($subjectDates); echo 'missing dates:' . "\r\n";; print_r($missingDates);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 13
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 44
Branch analysis from position: 63
2 jumps found. (Code = 77) Position 1 = 64, Position 2 = 78
Branch analysis from position: 64
2 jumps found. (Code = 78) Position 1 = 65, Position 2 = 78
Branch analysis from position: 65
2 jumps found. (Code = 77) Position 1 = 67, Position 2 = 76
Branch analysis from position: 67
2 jumps found. (Code = 78) Position 1 = 68, Position 2 = 76
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 76
Branch analysis from position: 78
2 jumps found. (Code = 77) Position 1 = 80, Position 2 = 88
Branch analysis from position: 80
2 jumps found. (Code = 78) Position 1 = 81, Position 2 = 88
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 85, Position 2 = 87
Branch analysis from position: 85
1 jumps found. (Code = 42) Position 1 = 80
Branch analysis from position: 80
Branch analysis from position: 87
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 88
Branch analysis from position: 78
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 44
Branch analysis from position: 63
Branch analysis from position: 44
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 13
Branch analysis from position: 32
Branch analysis from position: 13
filename:       /in/vHTDv
function name:  (null)
number of ops:  102
compiled vars:  !0 = $start, !1 = $days, !2 = $dateObj, !3 = $benchmarkDates, !4 = $i, !5 = $period, !6 = $interval, !7 = $dateObj0, !8 = $subject, !9 = $value, !10 = $key, !11 = $subjectDates, !12 = $missingDates
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                       !0, '2019-10-27+16%3A30%3A00'
    7     1        ASSIGN                                                       !1, 14
    8     2        NEW                                                  $15     'DateTimeImmutable'
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !2, $15
    9     6        INIT_METHOD_CALL                                             !2, 'format'
          7        SEND_VAL_EX                                                  'Y-m-d+H%3Ai%3As'
          8        DO_FCALL                                          0  $19     
          9        ASSIGN_DIM                                                   !3
         10        OP_DATA                                                      $19
   10    11        ASSIGN                                                       !4, 1
         12      > JMP                                                          ->30
   11    13    >   CONCAT                                               ~21     'P', !4
         14        CONCAT                                               ~22     ~21, 'D'
         15        ASSIGN                                                       !5, ~22
   12    16        NEW                                                  $24     'DateInterval'
         17        SEND_VAR_EX                                                  !5
         18        DO_FCALL                                          0          
         19        ASSIGN                                                       !6, $24
   13    20        INIT_METHOD_CALL                                             !2, 'add'
         21        SEND_VAR_EX                                                  !6
         22        DO_FCALL                                          0  $27     
         23        ASSIGN                                                       !7, $27
   14    24        INIT_METHOD_CALL                                             !7, 'format'
         25        SEND_VAL_EX                                                  'Y-m-d+H%3Ai%3As'
         26        DO_FCALL                                          0  $30     
         27        ASSIGN_DIM                                                   !3
         28        OP_DATA                                                      $30
   10    29        PRE_INC                                                      !4
         30    >   IS_SMALLER                                                   !4, !1
         31      > JMPNZ                                                        ~32, ->13
   21    32    >   ASSIGN                                                       !0, '2019-10-27+16%3A30%3A00'
   22    33        ASSIGN                                                       !1, 14
   23    34        NEW                                                  $35     'DateTimeImmutable'
         35        SEND_VAR_EX                                                  !0
         36        DO_FCALL                                          0          
         37        ASSIGN                                                       !2, $35
   24    38        INIT_ARRAY                                           ~40     !2, 'datum'
         39        FETCH_DIM_W                                          $38     !8, 0
         40        ASSIGN_DIM                                                   $38
         41        OP_DATA                                                      ~40
   25    42        ASSIGN                                                       !4, 2
         43      > JMP                                                          ->61
   26    44    >   CONCAT                                               ~42     'P', !4
         45        CONCAT                                               ~43     ~42, 'D'
         46        ASSIGN                                                       !5, ~43
   27    47        NEW                                                  $45     'DateInterval'
         48        SEND_VAR_EX                                                  !5
         49        DO_FCALL                                          0          
         50        ASSIGN                                                       !6, $45
   28    51        INIT_METHOD_CALL                                             !2, 'add'
         52        SEND_VAR_EX                                                  !6
         53        DO_FCALL                                          0  $48     
         54        ASSIGN                                                       !7, $48
   29    55        DIV                                                  ~50     !4, 2
         56        INIT_ARRAY                                           ~53     !7, 'datum'
         57        FETCH_DIM_W                                          $51     !8, ~50
         58        ASSIGN_DIM                                                   $51
         59        OP_DATA                                                      ~53
   25    60        ASSIGN_OP                                         1          !4, 2
         61    >   IS_SMALLER                                                   !4, !1
         62      > JMPNZ                                                        ~55, ->44
   34    63    > > FE_RESET_R                                           $56     !8, ->78
         64    > > FE_FETCH_R                                           ~57     $56, !9, ->78
         65    >   ASSIGN                                                       !10, ~57
   35    66      > FE_RESET_R                                           $59     !9, ->76
         67    > > FE_FETCH_R                                           ~60     $59, !9, ->76
         68    >   ASSIGN                                                       !10, ~60
   36    69        FETCH_DIM_R                                          ~63     !9, 'datum'
         70        INIT_METHOD_CALL                                             ~63, 'format'
         71        SEND_VAL_EX                                                  'Y-m-d+H%3Ai%3As'
         72        DO_FCALL                                          0  $64     
         73        ASSIGN_DIM                                                   !11
         74        OP_DATA                                                      $64
   35    75      > JMP                                                          ->67
         76    >   FE_FREE                                                      $59
   34    77      > JMP                                                          ->64
         78    >   FE_FREE                                                      $56
   45    79      > FE_RESET_R                                           $65     !3, ->88
         80    > > FE_FETCH_R                                           ~66     $65, !9, ->88
         81    >   ASSIGN                                                       !10, ~66
   46    82        FRAMELESS_ICALL_2                in_array            ~68     !9, !11
         83        BOOL_NOT                                             ~69     ~68
         84      > JMPZ                                                         ~69, ->87
   47    85    >   ASSIGN_DIM                                                   !12
         86        OP_DATA                                                      !9
   45    87    > > JMP                                                          ->80
         88    >   FE_FREE                                                      $65
   51    89        ECHO                                                         'benchmark+array%3A%0D%0A'
   52    90        INIT_FCALL                                                   'print_r'
         91        SEND_VAR                                                     !3
         92        DO_ICALL                                                     
   54    93        ECHO                                                         'subject+array%3A%0D%0A'
   55    94        INIT_FCALL                                                   'print_r'
         95        SEND_VAR                                                     !11
         96        DO_ICALL                                                     
   57    97        ECHO                                                         'missing+dates%3A%0D%0A'
   58    98        INIT_FCALL                                                   'print_r'
         99        SEND_VAR                                                     !12
        100        DO_ICALL                                                     
        101      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.58 ms | 2369 KiB | 14 Q