3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = []; $dt = new DateTime('first day of this month'); $month = $dt->format('n'); $dt->modify('-1 day'); while ($dt->modify('next weekday') && $dt->format('n') == $month) { $result[$dt->format('Y')][$dt->format('n')][] = $dt->format('d'); } var_export($result); echo "\n---\n"; $result = []; foreach ([2023, 2024] as $year) { $dt = new DateTime("$year-01-01 -1 day"); while ($dt->modify('next weekday') && $dt->format('Y') == $year) { $result[$year][$dt->format('n')][] = $dt->format('d'); } } var_export($result);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 13
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 71
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 71
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 46) Position 1 = 64, Position 2 = 69
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 70, Position 2 = 50
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 50
2 jumps found. (Code = 46) Position 1 = 64, Position 2 = 69
Branch analysis from position: 64
Branch analysis from position: 69
Branch analysis from position: 69
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
Branch analysis from position: 35
Branch analysis from position: 35
filename:       /in/8pPiX
function name:  (null)
number of ops:  76
compiled vars:  !0 = $result, !1 = $dt, !2 = $month, !3 = $year
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        NEW                                              $5      'DateTime'
          2        SEND_VAL_EX                                              'first+day+of+this+month'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $5
    5     5        INIT_METHOD_CALL                                         !1, 'format'
          6        SEND_VAL_EX                                              'n'
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !2, $8
    6     9        INIT_METHOD_CALL                                         !1, 'modify'
         10        SEND_VAL_EX                                              '-1+day'
         11        DO_FCALL                                      0          
    7    12      > JMP                                                      ->26
    8    13    >   INIT_METHOD_CALL                                         !1, 'format'
         14        SEND_VAL_EX                                              'Y'
         15        DO_FCALL                                      0  $11     
         16        INIT_METHOD_CALL                                         !1, 'format'
         17        SEND_VAL_EX                                              'n'
         18        DO_FCALL                                      0  $13     
         19        INIT_METHOD_CALL                                         !1, 'format'
         20        SEND_VAL_EX                                              'd'
         21        DO_FCALL                                      0  $16     
         22        FETCH_DIM_W                                      $12     !0, $11
         23        FETCH_DIM_W                                      $14     $12, $13
         24        ASSIGN_DIM                                               $14
         25        OP_DATA                                                  $16
    7    26    >   INIT_METHOD_CALL                                         !1, 'modify'
         27        SEND_VAL_EX                                              'next+weekday'
         28        DO_FCALL                                      0  $17     
         29      > JMPZ_EX                                          ~18     $17, ->35
         30    >   INIT_METHOD_CALL                                         !1, 'format'
         31        SEND_VAL_EX                                              'n'
         32        DO_FCALL                                      0  $19     
         33        IS_EQUAL                                         ~20     !2, $19
         34        BOOL                                             ~18     ~20
         35    > > JMPNZ                                                    ~18, ->13
   10    36    >   INIT_FCALL                                               'var_export'
         37        SEND_VAR                                                 !0
         38        DO_ICALL                                                 
   12    39        ECHO                                                     '%0A---%0A'
   14    40        ASSIGN                                                   !0, <array>
   15    41      > FE_RESET_R                                       $23     <array>, ->71
         42    > > FE_FETCH_R                                               $23, !3, ->71
   16    43    >   NEW                                              $24     'DateTime'
         44        NOP                                                      
         45        FAST_CONCAT                                      ~25     !3, '-01-01+-1+day'
         46        SEND_VAL_EX                                              ~25
         47        DO_FCALL                                      0          
         48        ASSIGN                                                   !1, $24
   17    49      > JMP                                                      ->60
   18    50    >   INIT_METHOD_CALL                                         !1, 'format'
         51        SEND_VAL_EX                                              'n'
         52        DO_FCALL                                      0  $29     
         53        INIT_METHOD_CALL                                         !1, 'format'
         54        SEND_VAL_EX                                              'd'
         55        DO_FCALL                                      0  $32     
         56        FETCH_DIM_W                                      $28     !0, !3
         57        FETCH_DIM_W                                      $30     $28, $29
         58        ASSIGN_DIM                                               $30
         59        OP_DATA                                                  $32
   17    60    >   INIT_METHOD_CALL                                         !1, 'modify'
         61        SEND_VAL_EX                                              'next+weekday'
         62        DO_FCALL                                      0  $33     
         63      > JMPZ_EX                                          ~34     $33, ->69
         64    >   INIT_METHOD_CALL                                         !1, 'format'
         65        SEND_VAL_EX                                              'Y'
         66        DO_FCALL                                      0  $35     
         67        IS_EQUAL                                         ~36     !3, $35
         68        BOOL                                             ~34     ~36
         69    > > JMPNZ                                                    ~34, ->50
   15    70    > > JMP                                                      ->42
         71    >   FE_FREE                                                  $23
   21    72        INIT_FCALL                                               'var_export'
         73        SEND_VAR                                                 !0
         74        DO_ICALL                                                 
         75      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.23 ms | 1002 KiB | 14 Q