3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Set demo vars $year = 2012; $months = array(10,11,12); $days = array(1,2,3,4,6,7,8,9,11,12,13,14,16,17,18,19,21,22,23,24,26,27,28,29); $dateWs = array(); foreach($months AS $month) foreach($days AS $day) $datesWS[] = new DateTime(implode('-',array($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' ))); // This way seems to work $excludeDates = array(); 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(array_values(array_map(function($obj){ return $obj->format('d/m/Y'); },$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 = 23
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 23
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 21
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 50
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 77) Position 1 = 70, Position 2 = 94
Branch analysis from position: 70
2 jumps found. (Code = 78) Position 1 = 71, Position 2 = 94
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 88, Position 2 = 93
Branch analysis from position: 88
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
Branch analysis from position: 93
Branch analysis from position: 94
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 94
Branch analysis from position: 50
2 jumps found. (Code = 77) Position 1 = 70, Position 2 = 94
Branch analysis from position: 70
Branch analysis from position: 94
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 50
Branch analysis from position: 45
Branch analysis from position: 50
Branch analysis from position: 23
filename:       /in/YeR9u
function name:  (null)
number of ops:  107
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 = $excludeDates, !12 = $date
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, ->23
          5    > > FE_FETCH_R                                               $17, !4, ->23
   10     6    > > FE_RESET_R                                       $18     !2, ->21
          7    > > FE_FETCH_R                                               $18, !5, ->21
   11     8    >   NEW                                              $20     'DateTime'
          9        INIT_FCALL                                               'implode'
         10        SEND_VAL                                                 '-'
         11        INIT_ARRAY                                       ~21     !0
         12        ADD_ARRAY_ELEMENT                                ~21     !4
         13        ADD_ARRAY_ELEMENT                                ~21     !5
         14        SEND_VAL                                                 ~21
         15        DO_ICALL                                         $22     
         16        SEND_VAR_NO_REF_EX                                       $22
         17        DO_FCALL                                      0          
         18        ASSIGN_DIM                                               !6
         19        OP_DATA                                                  $20
   10    20      > JMP                                                      ->7
         21    >   FE_FREE                                                  $18
    9    22      > JMP                                                      ->5
         23    >   FE_FREE                                                  $17
   14    24        INIT_FCALL                                               'shuffle'
         25        SEND_REF                                                 !6
         26        DO_ICALL                                                 
   18    27        INIT_FCALL                                               'usort'
         28        SEND_REF                                                 !6
         29        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYeR9u%3A18%240'
   20    30        SEND_VAL                                                 ~25
         31        DO_ICALL                                                 
   22    32        COUNT                                            ~27     !6
         33        IS_SMALLER                                               0, ~27
         34      > JMPZ                                                     ~28, ->40
         35    >   INIT_FCALL                                               'reset'
         36        SEND_REF                                                 !6
         37        DO_ICALL                                         $29     
         38        QM_ASSIGN                                        ~30     $29
         39      > JMP                                                      ->41
         40    >   QM_ASSIGN                                        ~30     0
         41    >   ASSIGN                                                   !7, ~30
   23    42        COUNT                                            ~32     !6
         43        IS_SMALLER                                               0, ~32
         44      > JMPZ                                                     ~33, ->50
         45    >   INIT_FCALL                                               'end'
         46        SEND_REF                                                 !6
         47        DO_ICALL                                         $34     
         48        QM_ASSIGN                                        ~35     $34
         49      > JMP                                                      ->51
         50    >   QM_ASSIGN                                        ~35     0
         51    >   ASSIGN                                                   !8, ~35
   24    52        NEW                                              $37     'DateInterval'
         53        SEND_VAL_EX                                              'P1D'
         54        DO_FCALL                                      0          
         55        ASSIGN                                                   !9, $37
   27    56        INIT_FCALL                                               'iterator_to_array'
         57        NEW                                              $40     'DatePeriod'
         58        SEND_VAR_EX                                              !7
         59        SEND_VAR_EX                                              !9
         60        INIT_METHOD_CALL                                         !8, 'modify'
         61        SEND_VAL_EX                                              '%2B1+day'
         62        DO_FCALL                                      0  $41     
         63        SEND_VAR_NO_REF_EX                                       $41
         64        DO_FCALL                                      0          
         65        SEND_VAR                                                 $40
         66        DO_ICALL                                         $43     
         67        ASSIGN                                                   !10, $43
   31    68        ASSIGN                                                   !11, <array>
   32    69      > FE_RESET_R                                       $46     !10, ->94
         70    > > FE_FETCH_R                                               $46, !12, ->94
   34    71    >   INIT_FCALL                                               'in_array'
         72        INIT_METHOD_CALL                                         !12, 'format'
         73        SEND_VAL_EX                                              'd%2Fm%2FY'
         74        DO_FCALL                                      0  $47     
         75        SEND_VAR                                                 $47
         76        INIT_FCALL                                               'array_values'
         77        INIT_FCALL                                               'array_map'
         78        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYeR9u%3A34%241'
   36    79        SEND_VAL                                                 ~48
         80        SEND_VAR                                                 !6
         81        DO_ICALL                                         $49     
         82        SEND_VAR                                                 $49
         83        DO_ICALL                                         $50     
         84        SEND_VAR                                                 $50
         85        DO_ICALL                                         $51     
         86        BOOL_NOT                                         ~52     $51
         87      > JMPZ                                                     ~52, ->93
   37    88    >   INIT_METHOD_CALL                                         !12, 'format'
         89        SEND_VAL_EX                                              'd%2Fm%2FY'
         90        DO_FCALL                                      0  $54     
         91        ASSIGN_DIM                                               !11
         92        OP_DATA                                                  $54
   32    93    > > JMP                                                      ->70
         94    >   FE_FREE                                                  $46
   40    95        INIT_FCALL                                               'var_dump'
         96        INIT_FCALL                                               'array_values'
         97        INIT_FCALL                                               'array_map'
         98        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYeR9u%3A40%242'
   42    99        SEND_VAL                                                 ~55
        100        SEND_VAR                                                 !11
        101        DO_ICALL                                         $56     
        102        SEND_VAR                                                 $56
        103        DO_ICALL                                         $57     
        104        SEND_VAR                                                 $57
        105        DO_ICALL                                                 
   68   106      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FYeR9u%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/YeR9u
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%2FYeR9u%3A18%240

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

End of function %00%7Bclosure%7D%2Fin%2FYeR9u%3A34%241

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

End of function %00%7Bclosure%7D%2Fin%2FYeR9u%3A40%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.87 ms | 1400 KiB | 33 Q