3v4l.org

run code in 300+ PHP versions simultaneously
<?php $basepath = '/home/robert/www/prod/htdocs'; $fullpath = '/home/robert/www/prod/htdocs/intra/announcements/index.php'; $b = explode('/',$basepath); $f = explode('/',$fullpath); $z = true; $max = 30; $i=0; while($z){ $bp = array_shift($b); $fp = array_shift($f); $z = $bp == $fp; $i++; if($i==$max) break; } array_unshift($f,$fp); $sfp = implode('/',$f); echo $sfp;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 16
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 30
filename:       /in/Vm36J
function name:  (null)
number of ops:  42
compiled vars:  !0 = $basepath, !1 = $fullpath, !2 = $b, !3 = $f, !4 = $z, !5 = $max, !6 = $i, !7 = $bp, !8 = $fp, !9 = $sfp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2Fhome%2Frobert%2Fwww%2Fprod%2Fhtdocs'
    4     1        ASSIGN                                                   !1, '%2Fhome%2Frobert%2Fwww%2Fprod%2Fhtdocs%2Fintra%2Fannouncements%2Findex.php'
    6     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2F'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $12     
          6        ASSIGN                                                   !2, $12
    7     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%2F'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $14     
         11        ASSIGN                                                   !3, $14
    9    12        ASSIGN                                                   !4, <true>
   10    13        ASSIGN                                                   !5, 30
         14        ASSIGN                                                   !6, 0
   11    15      > JMP                                                      ->30
   12    16    >   INIT_FCALL                                               'array_shift'
         17        SEND_REF                                                 !2
         18        DO_ICALL                                         $19     
         19        ASSIGN                                                   !7, $19
   13    20        INIT_FCALL                                               'array_shift'
         21        SEND_REF                                                 !3
         22        DO_ICALL                                         $21     
         23        ASSIGN                                                   !8, $21
   14    24        IS_EQUAL                                         ~23     !7, !8
         25        ASSIGN                                                   !4, ~23
   15    26        PRE_INC                                                  !6
   16    27        IS_EQUAL                                                 !6, !5
         28      > JMPZ                                                     ~26, ->30
         29    > > JMP                                                      ->31
   11    30    > > JMPNZ                                                    !4, ->16
   18    31    >   INIT_FCALL                                               'array_unshift'
         32        SEND_REF                                                 !3
         33        SEND_VAR                                                 !8
         34        DO_ICALL                                                 
   19    35        INIT_FCALL                                               'implode'
         36        SEND_VAL                                                 '%2F'
         37        SEND_VAR                                                 !3
         38        DO_ICALL                                         $28     
         39        ASSIGN                                                   !9, $28
   21    40        ECHO                                                     !9
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.61 ms | 1400 KiB | 21 Q