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,31); foreach($months AS $month) foreach($days AS $day) $datesWS[] = new DateTime(implode('-',array($year,$month,$day))); // Push DateTime object to the WebService array // 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 var_dump(array_shift($datesWS)); var_dump(array_pop($datesWS)); /* $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 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'); } // 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 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 36
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 46
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 46
Branch analysis from position: 41
Branch analysis from position: 46
Branch analysis from position: 22
filename:       /in/RM6O0
function name:  (null)
number of ops:  61
compiled vars:  !0 = $year, !1 = $months, !2 = $days, !3 = $month, !4 = $day, !5 = $datesWS, !6 = $dateIni, !7 = $dateEnd
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      > FE_RESET_R                                       $11     !1, ->22
          4    > > FE_FETCH_R                                               $11, !3, ->22
    9     5    > > FE_RESET_R                                       $12     !2, ->20
          6    > > FE_FETCH_R                                               $12, !4, ->20
   10     7    >   NEW                                              $14     'DateTime'
          8        INIT_FCALL                                               'implode'
          9        SEND_VAL                                                 '-'
         10        INIT_ARRAY                                       ~15     !0
         11        ADD_ARRAY_ELEMENT                                ~15     !3
         12        ADD_ARRAY_ELEMENT                                ~15     !4
         13        SEND_VAL                                                 ~15
         14        DO_ICALL                                         $16     
         15        SEND_VAR_NO_REF_EX                                       $16
         16        DO_FCALL                                      0          
         17        ASSIGN_DIM                                               !5
         18        OP_DATA                                                  $14
    9    19      > JMP                                                      ->6
         20    >   FE_FREE                                                  $12
    8    21      > JMP                                                      ->4
         22    >   FE_FREE                                                  $11
   13    23        INIT_FCALL                                               'usort'
         24        SEND_REF                                                 !5
         25        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FRM6O0%3A13%240'
   15    26        SEND_VAL                                                 ~18
         27        DO_ICALL                                                 
   17    28        COUNT                                            ~20     !5
         29        IS_SMALLER                                               0, ~20
         30      > JMPZ                                                     ~21, ->36
         31    >   INIT_FCALL                                               'reset'
         32        SEND_REF                                                 !5
         33        DO_ICALL                                         $22     
         34        QM_ASSIGN                                        ~23     $22
         35      > JMP                                                      ->37
         36    >   QM_ASSIGN                                        ~23     0
         37    >   ASSIGN                                                   !6, ~23
   18    38        COUNT                                            ~25     !5
         39        IS_SMALLER                                               0, ~25
         40      > JMPZ                                                     ~26, ->46
         41    >   INIT_FCALL                                               'end'
         42        SEND_REF                                                 !5
         43        DO_ICALL                                         $27     
         44        QM_ASSIGN                                        ~28     $27
         45      > JMP                                                      ->47
         46    >   QM_ASSIGN                                        ~28     0
         47    >   ASSIGN                                                   !7, ~28
   20    48        INIT_FCALL                                               'var_dump'
         49        INIT_FCALL                                               'array_shift'
         50        SEND_REF                                                 !5
         51        DO_ICALL                                         $30     
         52        SEND_VAR                                                 $30
         53        DO_ICALL                                                 
   21    54        INIT_FCALL                                               'var_dump'
         55        INIT_FCALL                                               'array_pop'
         56        SEND_REF                                                 !5
         57        DO_ICALL                                         $32     
         58        SEND_VAR                                                 $32
         59        DO_ICALL                                                 
   64    60      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FRM6O0%3A13%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/RM6O0
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     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
   15    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FRM6O0%3A13%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.31 ms | 1404 KiB | 27 Q