3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = 16; $day = "Wednesday"; $x=0; $start = date("Y-m-") . $date; While(date("l", strtotime($start ."-" .$x . "months")) != $day){ $x++; } Echo $x . " months ago.";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
Branch analysis from position: 9
filename:       /in/vUYeX
function name:  (null)
number of ops:  25
compiled vars:  !0 = $date, !1 = $day, !2 = $x, !3 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 16
    4     1        ASSIGN                                                   !1, 'Wednesday'
    5     2        ASSIGN                                                   !2, 0
    7     3        INIT_FCALL                                               'date'
          4        SEND_VAL                                                 'Y-m-'
          5        DO_ICALL                                         $7      
          6        CONCAT                                           ~8      $7, !0
          7        ASSIGN                                                   !3, ~8
    9     8      > JMP                                                      ->10
   10     9    >   PRE_INC                                                  !2
    9    10    >   INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'l'
         12        INIT_FCALL                                               'strtotime'
         13        CONCAT                                           ~11     !3, '-'
         14        CONCAT                                           ~12     ~11, !2
         15        CONCAT                                           ~13     ~12, 'months'
         16        SEND_VAL                                                 ~13
         17        DO_ICALL                                         $14     
         18        SEND_VAR                                                 $14
         19        DO_ICALL                                         $15     
         20        IS_NOT_EQUAL                                             !1, $15
         21      > JMPNZ                                                    ~16, ->9
   12    22    >   CONCAT                                           ~17     !2, '+months+ago.'
         23        ECHO                                                     ~17
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.61 ms | 999 KiB | 15 Q