3v4l.org

run code in 500+ PHP versions simultaneously
<?php $url = 'http://website.com/category/sub-category/product/?asdsadasdas'; $data = explode('/',$url); echo join('/',array_slice($data,0,4)); //string(27) "http://website.com/category"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fqh00
function name:  (null)
number of ops:  17
compiled vars:  !0 = $url, !1 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'http%3A%2F%2Fwebsite.com%2Fcategory%2Fsub-category%2Fproduct%2F%3Fasdsadasdas'
    5     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%2F'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $3      
          5        ASSIGN                                                       !1, $3
    6     6        INIT_FCALL                                                   'join'
          7        SEND_VAL                                                     '%2F'
          8        INIT_FCALL                                                   'array_slice'
          9        SEND_VAR                                                     !1
         10        SEND_VAL                                                     0
         11        SEND_VAL                                                     4
         12        DO_ICALL                                             $5      
         13        SEND_VAR                                                     $5
         14        DO_ICALL                                             $6      
         15        ECHO                                                         $6
    7    16      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.2 ms | 1431 KiB | 11 Q