3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = new DateTime("first day of next month"); $publicHolidays = ['01-01', '05-01']; // Format: mm-dd while (true) { // format("N") >= 6 == Weekend if ($date->format("N") >= 6) { // If Saturday or Sunday, add 1 or 2 days. // N=6 (Saturday), 8-6 = 2, get monday // N=7 (Sunday), 8-7 = 1, get monday $date->modify("+".(8-$date->format("N"))." days"); } elseif (in_array($date->format("m-d"), $publicHolidays)) { // This day is a public holiday! Add one. $date->modify("+1 day"); } else { break; } } echo $date->format("Y-m-d");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 6
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
filename:       /in/tlDMl
function name:  (null)
number of ops:  40
compiled vars:  !0 = $date, !1 = $publicHolidays
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'DateTime'
          1        SEND_VAL_EX                                              'first+day+of+next+month'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
    4     4        ASSIGN                                                   !1, <array>
    6     5      > JMP                                                      ->34
    8     6    >   INIT_METHOD_CALL                                         !0, 'format'
          7        SEND_VAL_EX                                              'N'
          8        DO_FCALL                                      0  $6      
          9        IS_SMALLER_OR_EQUAL                                      6, $6
         10      > JMPZ                                                     ~7, ->21
   12    11    >   INIT_METHOD_CALL                                         !0, 'modify'
         12        INIT_METHOD_CALL                                         !0, 'format'
         13        SEND_VAL_EX                                              'N'
         14        DO_FCALL                                      0  $8      
         15        SUB                                              ~9      8, $8
         16        CONCAT                                           ~10     '%2B', ~9
         17        CONCAT                                           ~11     ~10, '+days'
         18        SEND_VAL_EX                                              ~11
         19        DO_FCALL                                      0          
    8    20      > JMP                                                      ->34
   13    21    >   INIT_FCALL                                               'in_array'
         22        INIT_METHOD_CALL                                         !0, 'format'
         23        SEND_VAL_EX                                              'm-d'
         24        DO_FCALL                                      0  $13     
         25        SEND_VAR                                                 $13
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $14     
         28      > JMPZ                                                     $14, ->33
   15    29    >   INIT_METHOD_CALL                                         !0, 'modify'
         30        SEND_VAL_EX                                              '%2B1+day'
         31        DO_FCALL                                      0          
   13    32      > JMP                                                      ->34
   17    33    > > JMP                                                      ->35
    6    34    > > JMPNZ                                                    <true>, ->6
   21    35    >   INIT_METHOD_CALL                                         !0, 'format'
         36        SEND_VAL_EX                                              'Y-m-d'
         37        DO_FCALL                                      0  $16     
         38        ECHO                                                     $16
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.66 ms | 1005 KiB | 14 Q