3v4l.org

run code in 300+ PHP versions simultaneously
<?php $days = []; $searchData = ['dat' => '2015-11-11']; $offset = 3; $now = date_create('today'); $offsetStart = -1 * $offset; echo date_create($searchData['dat'])->modify($offsetStart .' days')->format('Y-m-d H:i'); echo PHP_EOL . $now->format('Y-m-d H:i'); echo PHP_EOL . date_create($searchData['dat'])->diff($now)->days; if (date_create($searchData['dat'])->modify($offsetStart .' days') < $now) { $offsetStart = -1 * date_create($searchData['dat'])->diff($now)->days; } $offsetEnd = 2 * $offset + $offsetStart; for ($i = $offsetStart; $i <= $offsetEnd; $i++) { $days[] = $i; } print_r($days);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 56
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 61
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 61
Branch analysis from position: 66
Branch analysis from position: 61
Branch analysis from position: 56
filename:       /in/V40N2
function name:  (null)
number of ops:  70
compiled vars:  !0 = $days, !1 = $searchData, !2 = $offset, !3 = $now, !4 = $offsetStart, !5 = $offsetEnd, !6 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, 3
    6     3        INIT_FCALL                                               'date_create'
          4        SEND_VAL                                                 'today'
          5        DO_ICALL                                         $10     
          6        ASSIGN                                                   !3, $10
    8     7        MUL                                              ~12     !2, -1
          8        ASSIGN                                                   !4, ~12
    9     9        INIT_FCALL                                               'date_create'
         10        FETCH_DIM_R                                      ~14     !1, 'dat'
         11        SEND_VAL                                                 ~14
         12        DO_ICALL                                         $15     
         13        INIT_METHOD_CALL                                         $15, 'modify'
         14        CONCAT                                           ~16     !4, '+days'
         15        SEND_VAL_EX                                              ~16
         16        DO_FCALL                                      0  $17     
         17        INIT_METHOD_CALL                                         $17, 'format'
         18        SEND_VAL_EX                                              'Y-m-d+H%3Ai'
         19        DO_FCALL                                      0  $18     
         20        ECHO                                                     $18
   10    21        INIT_METHOD_CALL                                         !3, 'format'
         22        SEND_VAL_EX                                              'Y-m-d+H%3Ai'
         23        DO_FCALL                                      0  $19     
         24        CONCAT                                           ~20     '%0A', $19
         25        ECHO                                                     ~20
   11    26        INIT_FCALL                                               'date_create'
         27        FETCH_DIM_R                                      ~21     !1, 'dat'
         28        SEND_VAL                                                 ~21
         29        DO_ICALL                                         $22     
         30        INIT_METHOD_CALL                                         $22, 'diff'
         31        SEND_VAR_EX                                              !3
         32        DO_FCALL                                      0  $23     
         33        FETCH_OBJ_R                                      ~24     $23, 'days'
         34        CONCAT                                           ~25     '%0A', ~24
         35        ECHO                                                     ~25
   12    36        INIT_FCALL                                               'date_create'
         37        FETCH_DIM_R                                      ~26     !1, 'dat'
         38        SEND_VAL                                                 ~26
         39        DO_ICALL                                         $27     
         40        INIT_METHOD_CALL                                         $27, 'modify'
         41        CONCAT                                           ~28     !4, '+days'
         42        SEND_VAL_EX                                              ~28
         43        DO_FCALL                                      0  $29     
         44        IS_SMALLER                                               $29, !3
         45      > JMPZ                                                     ~30, ->56
   13    46    >   INIT_FCALL                                               'date_create'
         47        FETCH_DIM_R                                      ~31     !1, 'dat'
         48        SEND_VAL                                                 ~31
         49        DO_ICALL                                         $32     
         50        INIT_METHOD_CALL                                         $32, 'diff'
         51        SEND_VAR_EX                                              !3
         52        DO_FCALL                                      0  $33     
         53        FETCH_OBJ_R                                      ~34     $33, 'days'
         54        MUL                                              ~35     ~34, -1
         55        ASSIGN                                                   !4, ~35
   15    56    >   MUL                                              ~37     !2, 2
         57        ADD                                              ~38     ~37, !4
         58        ASSIGN                                                   !5, ~38
   17    59        ASSIGN                                                   !6, !4
         60      > JMP                                                      ->64
   18    61    >   ASSIGN_DIM                                               !0
         62        OP_DATA                                                  !6
   17    63        PRE_INC                                                  !6
         64    >   IS_SMALLER_OR_EQUAL                                      !6, !5
         65      > JMPNZ                                                    ~43, ->61
   21    66    >   INIT_FCALL                                               'print_r'
         67        SEND_VAR                                                 !0
         68        DO_ICALL                                                 
         69      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
259.74 ms | 1400 KiB | 17 Q