3v4l.org

run code in 500+ PHP versions simultaneously
<?php $replacements = array('value1' => 10000, 'external' => 'AAAAA'); $url = 'http://example.com/values?value1=12121&order=3&external=AFB3432'; // extract the query part $query = parse_url($url, PHP_URL_QUERY); // and parse it into variables parse_str($query, $params); // merge the parameter values with the replacements $new_params = array_merge($params, $replacements); // create a new query string $new_query = http_build_query($new_params); // and reassemble the URL $new_url = parse_url($url, PHP_URL_SCHEME) . "://" . parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH) . "?" . $new_query; echo $new_url;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vguDV
function name:  (null)
number of ops:  40
compiled vars:  !0 = $replacements, !1 = $url, !2 = $query, !3 = $params, !4 = $new_params, !5 = $new_query, !6 = $new_url
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, 'http%3A%2F%2Fexample.com%2Fvalues%3Fvalue1%3D12121%26order%3D3%26external%3DAFB3432'
    6     2        INIT_FCALL                                                   'parse_url'
          3        SEND_VAR                                                     !1
          4        SEND_VAL                                                     6
          5        DO_ICALL                                             $9      
          6        ASSIGN                                                       !2, $9
    8     7        INIT_FCALL                                                   'parse_str'
          8        SEND_VAR                                                     !2
          9        SEND_REF                                                     !3
         10        DO_ICALL                                                     
   10    11        INIT_FCALL                                                   'array_merge'
         12        SEND_VAR                                                     !3
         13        SEND_VAR                                                     !0
         14        DO_ICALL                                             $12     
         15        ASSIGN                                                       !4, $12
   12    16        INIT_FCALL                                                   'http_build_query'
         17        SEND_VAR                                                     !4
         18        DO_ICALL                                             $14     
         19        ASSIGN                                                       !5, $14
   14    20        INIT_FCALL                                                   'parse_url'
         21        SEND_VAR                                                     !1
         22        SEND_VAL                                                     0
         23        DO_ICALL                                             $16     
         24        CONCAT                                               ~17     $16, '%3A%2F%2F'
         25        INIT_FCALL                                                   'parse_url'
         26        SEND_VAR                                                     !1
         27        SEND_VAL                                                     1
         28        DO_ICALL                                             $18     
         29        CONCAT                                               ~19     ~17, $18
         30        INIT_FCALL                                                   'parse_url'
         31        SEND_VAR                                                     !1
         32        SEND_VAL                                                     5
         33        DO_ICALL                                             $20     
         34        CONCAT                                               ~21     ~19, $20
         35        CONCAT                                               ~22     ~21, '%3F'
         36        CONCAT                                               ~23     ~22, !5
         37        ASSIGN                                                       !6, ~23
   15    38        ECHO                                                         !6
   16    39      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.92 ms | 2581 KiB | 17 Q