3v4l.org

run code in 300+ PHP versions simultaneously
<?php function removeVar($url, $key) { $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); $url = substr($url, 0, -1); return $url; } $url = "/search/listing.html?vehicle_type=&year=&make_name=&model_name=&loc_type=3&zipcode=641004&distance=100&make_order=ASC"; $newUrl = removeVar($url, "make_order"); echo $newUrl;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tjt4I
function name:  (null)
number of ops:  8
compiled vars:  !0 = $url, !1 = $newUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, '%2Fsearch%2Flisting.html%3Fvehicle_type%3D%26year%3D%26make_name%3D%26model_name%3D%26loc_type%3D3%26zipcode%3D641004%26distance%3D100%26make_order%3DASC'
   10     1        INIT_FCALL                                               'removevar'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'make_order'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !1, $3
   12     6        ECHO                                                     !1
          7      > RETURN                                                   1

Function removevar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tjt4I
function name:  removeVar
number of ops:  19
compiled vars:  !0 = $url, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'preg_replace'
          3        CONCAT                                           ~2      '%2F%28.%2A%29%28%3F%7C%26%29', !1
          4        CONCAT                                           ~3      ~2, '%3D%5B%5E%26%5D%2B%3F%28%26%29%28.%2A%29%2Fi'
          5        SEND_VAL                                                 ~3
          6        SEND_VAL                                                 '%241%242%244'
          7        CONCAT                                           ~4      !0, '%26'
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !0, $5
    5    11        INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 0
         14        SEND_VAL                                                 -1
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !0, $7
    6    17      > RETURN                                                   !0
    7    18*     > RETURN                                                   null

End of function removevar

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.6 ms | 1399 KiB | 18 Q