3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Set demo vars $year = '2012'; $months = array('10','11','12'); $days = array('01','02','03','04','06','07','08','09','11','12','13','14','16','17','18','19','21','22','23','24','26','27','28','30'); $dateWs = array(); foreach($months AS $month) foreach($days AS $day) $datesWS[] = new DateTime($year.'-'.$month.'-'.$day); // Push DateTime object to the WebService array // Shuffle shuffle($datesWS); // Sort dates usort($datesWS, function ($a, $b){ return ($a == $b) ? 0 : (($a > $b) ? 1 : -1); }); $dateIni = count($datesWS)>0 ? reset($datesWS) : 0; // Get first date $dateEnd = count($datesWS)>0 ? end($datesWS) : 0; // Get last date $interval = new DateInterval('P1D'); // Set date interval as 1 day // Generate dates range and Transform iterator to array $datesRange = iterator_to_array(new DatePeriod($dateIni, $interval, $dateEnd->modify( '+1 day' ))); var_dump($datesWS); die(); // This way seems to work foreach($datesRange AS $date) { if(!in_array($date->format('d/m/Y'),array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesWS)))) $excludeDates[] = $date->format('d/m/Y'); } var_dump($excludeDates); /* // This way should be more efficient, but I'm fed up with it! // Get excluded dates $excludeDates = array_udiff($datesRange, $datesWS, function ($a, $b) { return $a == $b ? 0 : 1; }); // Comment/Uncomment this in order to print this method or the other one // Print array(objects) as array(strings) var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesWS))); var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$datesRange))); var_dump(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$excludeDates))); */ ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 47
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 47
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 47
Branch analysis from position: 42
Branch analysis from position: 47
Branch analysis from position: 20
filename:       /in/X8Nqa
function name:  (null)
number of ops:  99
compiled vars:  !0 = $year, !1 = $months, !2 = $days, !3 = $dateWs, !4 = $month, !5 = $day, !6 = $datesWS, !7 = $dateIni, !8 = $dateEnd, !9 = $interval, !10 = $datesRange, !11 = $date, !12 = $excludeDates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '2012'
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
    8     3        ASSIGN                                                   !3, <array>
    9     4      > FE_RESET_R                                       $17     !1, ->20
          5    > > FE_FETCH_R                                               $17, !4, ->20
   10     6    > > FE_RESET_R                                       $18     !2, ->18
          7    > > FE_FETCH_R                                               $18, !5, ->18
   11     8    >   NEW                                              $20     'DateTime'
          9        CONCAT                                           ~21     !0, '-'
         10        CONCAT                                           ~22     ~21, !4
         11        CONCAT                                           ~23     ~22, '-'
         12        CONCAT                                           ~24     ~23, !5
         13        SEND_VAL_EX                                              ~24
         14        DO_FCALL                                      0          
         15        ASSIGN_DIM                                               !6
         16        OP_DATA                                                  $20
   10    17      > JMP                                                      ->7
         18    >   FE_FREE                                                  $18
    9    19      > JMP                                                      ->5
         20    >   FE_FREE                                                  $17
   14    21        INIT_FCALL                                               'shuffle'
         22        SEND_REF                                                 !6
         23        DO_ICALL                                                 
   18    24        INIT_FCALL                                               'usort'
         25        SEND_REF                                                 !6
         26        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FX8Nqa%3A18%240'
   20    27        SEND_VAL                                                 ~27
         28        DO_ICALL                                                 
   22    29        COUNT                                            ~29     !6
         30        IS_SMALLER                                               0, ~29
         31      > JMPZ                                                     ~30, ->37
         32    >   INIT_FCALL                                               'reset'
         33        SEND_REF                                                 !6
         34        DO_ICALL                                         $31     
         35        QM_ASSIGN                                        ~32     $31
         36      > JMP                                                      ->38
         37    >   QM_ASSIGN                                        ~32     0
         38    >   ASSIGN                                                   !7, ~32
   23    39        COUNT                                            ~34     !6
         40        IS_SMALLER                                               0, ~34
         41      > JMPZ                                                     ~35, ->47
         42    >   INIT_FCALL                                               'end'
         43        SEND_REF                                                 !6
         44        DO_ICALL                                         $36     
         45        QM_ASSIGN                                        ~37     $36
         46      > JMP                                                      ->48
         47    >   QM_ASSIGN                                        ~37     0
         48    >   ASSIGN                                                   !8, ~37
   24    49        NEW                                              $39     'DateInterval'
         50        SEND_VAL_EX                                              'P1D'
         51        DO_FCALL                                      0          
         52        ASSIGN                                                   !9, $39
   27    53        INIT_FCALL                                               'iterator_to_array'
         54        NEW                                              $42     'DatePeriod'
         55        SEND_VAR_EX                                              !7
         56        SEND_VAR_EX                                              !9
         57        INIT_METHOD_CALL                                         !8, 'modify'
         58        SEND_VAL_EX                                              '%2B1+day'
         59        DO_FCALL                                      0  $43     
         60        SEND_VAR_NO_REF_EX                                       $43
         61        DO_FCALL                                      0          
         62        SEND_VAR                                                 $42
         63        DO_ICALL                                         $45     
         64        ASSIGN                                                   !10, $45
   29    65        INIT_FCALL                                               'var_dump'
         66        SEND_VAR                                                 !6
         67        DO_ICALL                                                 
   30    68      > EXIT                                                     
   33    69*       FE_RESET_R                                       $48     !10, ->94
         70*       FE_FETCH_R                                               $48, !11, ->94
   35    71*       INIT_FCALL                                               'in_array'
         72*       INIT_METHOD_CALL                                         !11, 'format'
         73*       SEND_VAL_EX                                              'd%2Fm%2FY'
         74*       DO_FCALL                                      0  $49     
         75*       SEND_VAR                                                 $49
         76*       INIT_FCALL                                               'array_values'
         77*       INIT_FCALL                                               'array_map'
         78*       DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FX8Nqa%3A35%241'
   37    79*       SEND_VAL                                                 ~50
         80*       SEND_VAR                                                 !6
         81*       DO_ICALL                                         $51     
         82*       SEND_VAR                                                 $51
         83*       DO_ICALL                                         $52     
         84*       SEND_VAR                                                 $52
         85*       DO_ICALL                                         $53     
         86*       BOOL_NOT                                         ~54     $53
         87*       JMPZ                                                     ~54, ->93
   38    88*       INIT_METHOD_CALL                                         !11, 'format'
         89*       SEND_VAL_EX                                              'd%2Fm%2FY'
         90*       DO_FCALL                                      0  $56     
         91*       ASSIGN_DIM                                               !12
         92*       OP_DATA                                                  $56
   33    93*       JMP                                                      ->70
         94*       FE_FREE                                                  $48
   41    95*       INIT_FCALL                                               'var_dump'
         96*       SEND_VAR                                                 !12
         97*       DO_ICALL                                                 
   67    98*     > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FX8Nqa%3A18%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X8Nqa
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        IS_EQUAL                                                 !0, !1
          3      > JMPZ                                                     ~2, ->6
          4    >   QM_ASSIGN                                        ~3      0
          5      > JMP                                                      ->12
          6    >   IS_SMALLER                                               !1, !0
          7      > JMPZ                                                     ~4, ->10
          8    >   QM_ASSIGN                                        ~5      1
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~5      -1
         11    >   QM_ASSIGN                                        ~3      ~5
         12    > > RETURN                                                   ~3
   20    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FX8Nqa%3A18%240

Function %00%7Bclosure%7D%2Fin%2FX8Nqa%3A35%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X8Nqa
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        INIT_METHOD_CALL                                         !0, 'format'
          2        SEND_VAL_EX                                              'd%2Fm%2FY'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   37     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FX8Nqa%3A35%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.05 ms | 1408 KiB | 31 Q