3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = '/www/proj-asd/app/home/news'; $b = '/www/proj-asd/app/_view'; echo getRelPath($a, $b); // home/news function getRelPath($a, $b) { $a = explode('/', $a); $b = explode('/', $b); $diff = array_diff_assoc($a, $b); return implode('/', $diff); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eB8Km
function name:  (null)
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '%2Fwww%2Fproj-asd%2Fapp%2Fhome%2Fnews'
    5     1        ASSIGN                                                   !1, '%2Fwww%2Fproj-asd%2Fapp%2F_view'
    7     2        INIT_FCALL_BY_NAME                                       'getRelPath'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   16     7      > RETURN                                                   1

Function getrelpath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eB8Km
function name:  getRelPath
number of ops:  23
compiled vars:  !0 = $a, !1 = $b, !2 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%2F'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !0, $3
   12     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%2F'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !1, $5
   13    12        INIT_FCALL                                               'array_diff_assoc'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !2, $7
   15    17        INIT_FCALL                                               'implode'
         18        SEND_VAL                                                 '%2F'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $9      
         21      > RETURN                                                   $9
   16    22*     > RETURN                                                   null

End of function getrelpath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.44 ms | 1003 KiB | 16 Q