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) { $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/t5b2p
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
   21     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 = 42
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 42
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 41
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 41
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/t5b2p
function name:  getRelativePath
number of ops:  50
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, ->42
         28    > > FE_FETCH_R                                       ~21     $20, !7, ->42
         29    >   ASSIGN                                                   !8, ~21
   15    30        INIT_FCALL                                               'array_shift'
         31        SEND_REF                                                 !5
         32        DO_ICALL                                         $23     
         33        ASSIGN                                                   !9, $23
   16    34        IS_NOT_IDENTICAL                                         !9, !7
         35      > JMPZ                                                     ~25, ->41
   17    36    >   CONCAT                                           ~26     !3, '..'
         37        CONCAT                                           ~27     ~26, !6
         38        CONCAT                                           ~28     ~27, !9
         39        CONCAT                                           ~29     ~28, !3
         40        ASSIGN                                                   !6, ~29
   14    41    > > JMP                                                      ->28
         42    >   FE_FREE                                                  $20
   20    43        INIT_FCALL                                               'implode'
         44        SEND_VAR                                                 !3
         45        SEND_VAR                                                 !5
         46        DO_ICALL                                         $31     
         47        CONCAT                                           ~32     !6, $31
         48      > RETURN                                                   ~32
   21    49*     > RETURN                                                   null

End of function getrelativepath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.66 ms | 1400 KiB | 23 Q