3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo getRelativePath("/mnt/hgfs/home/Project1/src/AppBundle/Form/RegistrationType.php", "/mnt/hgfs/home/Project1/app"); function getRelativePath($path, $rootPath, $maxDepthCheck = 10){ if (0 === strpos($path, $rootPath)) { return substr($path, strlen($rootPath)); } $ds = DIRECTORY_SEPARATOR; $rootDirectoryArray = explode($ds, $rootPath); $pathDirectoryArray = explode($ds, $path); $relativePath = $ds; foreach ($rootDirectoryArray as $index => $rootCurrentDirectory) { var_dump($pathDirectoryArray); $pathCurrentDirectory = array_shift($pathDirectoryArray); if ($pathCurrentDirectory !== $rootCurrentDirectory) { $relativePath = $ds . '..' . $relativePath . $pathCurrentDirectory . $ds; } } return $relativePath.implode($ds, $pathDirectoryArray); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vavd0
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'getRelativePath'
          1        SEND_VAL_EX                                              '%2Fmnt%2Fhgfs%2Fhome%2FProject1%2Fsrc%2FAppBundle%2FForm%2FRegistrationType.php'
          2        SEND_VAL_EX                                              '%2Fmnt%2Fhgfs%2Fhome%2FProject1%2Fapp'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
   22     5      > RETURN                                                   1

Function getrelativepath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 45
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 45
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 44
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 44
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
filename:       /in/Vavd0
function name:  getRelativePath
number of ops:  53
compiled vars:  !0 = $path, !1 = $rootPath, !2 = $maxDepthCheck, !3 = $ds, !4 = $rootDirectoryArray, !5 = $pathDirectoryArray, !6 = $relativePath, !7 = $rootCurrentDirectory, !8 = $index, !9 = $pathCurrentDirectory
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      10
    6     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $10     
          7        IS_IDENTICAL                                             $10, 0
          8      > JMPZ                                                     ~11, ->15
    7     9    >   INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        STRLEN                                           ~12     !1
         12        SEND_VAL                                                 ~12
         13        DO_ICALL                                         $13     
         14      > RETURN                                                   $13
    9    15    >   ASSIGN                                                   !3, '%2F'
   10    16        INIT_FCALL                                               'explode'
         17        SEND_VAR                                                 !3
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $15     
         20        ASSIGN                                                   !4, $15
   11    21        INIT_FCALL                                               'explode'
         22        SEND_VAR                                                 !3
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                         $17     
         25        ASSIGN                                                   !5, $17
   12    26        ASSIGN                                                   !6, !3
   14    27      > FE_RESET_R                                       $20     !4, ->45
         28    > > FE_FETCH_R                                       ~21     $20, !7, ->45
         29    >   ASSIGN                                                   !8, ~21
   15    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !5
         32        DO_ICALL                                                 
   16    33        INIT_FCALL                                               'array_shift'
         34        SEND_REF                                                 !5
         35        DO_ICALL                                         $24     
         36        ASSIGN                                                   !9, $24
   17    37        IS_NOT_IDENTICAL                                         !9, !7
         38      > JMPZ                                                     ~26, ->44
   18    39    >   CONCAT                                           ~27     !3, '..'
         40        CONCAT                                           ~28     ~27, !6
         41        CONCAT                                           ~29     ~28, !9
         42        CONCAT                                           ~30     ~29, !3
         43        ASSIGN                                                   !6, ~30
   14    44    > > JMP                                                      ->28
         45    >   FE_FREE                                                  $20
   21    46        INIT_FCALL                                               'implode'
         47        SEND_VAR                                                 !3
         48        SEND_VAR                                                 !5
         49        DO_ICALL                                         $32     
         50        CONCAT                                           ~33     !6, $32
         51      > RETURN                                                   ~33
   22    52*     > RETURN                                                   null

End of function getrelativepath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.25 ms | 1400 KiB | 25 Q