3v4l.org

run code in 300+ PHP versions simultaneously
<?php function joinPath($arguments) { $path = ''; $args = array(); foreach($arguments as $a) if($a !== '') $args[] = $a;//Removes the empty elements $arg_count = count($args); for($i=0; $i<$arg_count; $i++) { $folder = $args[$i]; if($i != 0 and $folder[0] == DIRECTORY_SEPARATOR) $folder = substr($folder,1); //Remove the first char if it is a '/' - and its not in the first argument if($i != $arg_count-1 and substr($folder,-1) == DIRECTORY_SEPARATOR) $folder = substr($folder,0,-1); //Remove the last char - if its not in the last argument $path .= $folder; if($i != $arg_count-1) $path .= DIRECTORY_SEPARATOR; //Add the '/' if its not the last element. } return $path; } print(joinPath(array("blah", "", "gda", "")));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3DUME
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'joinpath'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function joinpath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 9
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 15
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 44
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 49
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 15
Branch analysis from position: 52
Branch analysis from position: 15
Branch analysis from position: 49
Branch analysis from position: 44
Branch analysis from position: 37
Branch analysis from position: 28
Branch analysis from position: 22
Branch analysis from position: 10
filename:       /in/3DUME
function name:  joinPath
number of ops:  54
compiled vars:  !0 = $arguments, !1 = $path, !2 = $args, !3 = $a, !4 = $arg_count, !5 = $i, !6 = $folder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, ''
    4     2        ASSIGN                                                   !2, <array>
    5     3      > FE_RESET_R                                       $9      !0, ->10
          4    > > FE_FETCH_R                                               $9, !3, ->10
          5    >   IS_NOT_IDENTICAL                                         !3, ''
          6      > JMPZ                                                     ~10, ->9
          7    >   ASSIGN_DIM                                               !2
          8        OP_DATA                                                  !3
          9    > > JMP                                                      ->4
         10    >   FE_FREE                                                  $9
    7    11        COUNT                                            ~12     !2
         12        ASSIGN                                                   !4, ~12
    8    13        ASSIGN                                                   !5, 0
         14      > JMP                                                      ->50
    9    15    >   FETCH_DIM_R                                      ~15     !2, !5
         16        ASSIGN                                                   !6, ~15
   11    17        IS_NOT_EQUAL                                     ~17     !5, 0
         18      > JMPZ_EX                                          ~17     ~17, ->22
         19    >   FETCH_DIM_R                                      ~18     !6, 0
         20        IS_EQUAL                                         ~19     ~18, '%2F'
         21        BOOL                                             ~17     ~19
         22    > > JMPZ                                                     ~17, ->28
         23    >   INIT_FCALL                                               'substr'
         24        SEND_VAR                                                 !6
         25        SEND_VAL                                                 1
         26        DO_ICALL                                         $20     
         27        ASSIGN                                                   !6, $20
   12    28    >   SUB                                              ~22     !4, 1
         29        IS_NOT_EQUAL                                     ~23     !5, ~22
         30      > JMPZ_EX                                          ~23     ~23, ->37
         31    >   INIT_FCALL                                               'substr'
         32        SEND_VAR                                                 !6
         33        SEND_VAL                                                 -1
         34        DO_ICALL                                         $24     
         35        IS_EQUAL                                         ~25     $24, '%2F'
         36        BOOL                                             ~23     ~25
         37    > > JMPZ                                                     ~23, ->44
         38    >   INIT_FCALL                                               'substr'
         39        SEND_VAR                                                 !6
         40        SEND_VAL                                                 0
         41        SEND_VAL                                                 -1
         42        DO_ICALL                                         $26     
         43        ASSIGN                                                   !6, $26
   14    44    >   ASSIGN_OP                                     8          !1, !6
   15    45        SUB                                              ~29     !4, 1
         46        IS_NOT_EQUAL                                             !5, ~29
         47      > JMPZ                                                     ~30, ->49
         48    >   ASSIGN_OP                                     8          !1, '%2F'
    8    49    >   PRE_INC                                                  !5
         50    >   IS_SMALLER                                               !5, !4
         51      > JMPNZ                                                    ~33, ->15
   17    52    > > RETURN                                                   !1
   18    53*     > RETURN                                                   null

End of function joinpath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.48 ms | 1403 KiB | 16 Q