3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'https://www.somehost.com/test/index.html?param1=4&param2=3&param3=2&param4=1&param5=3'; function parse($str) { // parse string to uri array $uri = parse_url($str); // parse query params to array parse_str($uri['query'], $params); // task1. filter params by 3 $params = array_filter($params, function($p) { return (int)$p !== 3; }); // task2. sort params asort($params); // task3. get url $params['url'] = $uri['path']; return $uri['scheme'] . '://' . $uri['host'] . '/?' . http_build_query($params); } echo parse($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9busa
function name:  (null)
number of ops:  6
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'https%3A%2F%2Fwww.somehost.com%2Ftest%2Findex.html%3Fparam1%3D4%26param2%3D3%26param3%3D2%26param4%3D1%26param5%3D3'
   25     1        INIT_FCALL                                               'parse'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function parse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9busa
function name:  parse
number of ops:  33
compiled vars:  !0 = $str, !1 = $uri, !2 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'parse_url'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
    9     5        INIT_FCALL                                               'parse_str'
          6        FETCH_DIM_R                                      ~5      !1, 'query'
          7        SEND_VAL                                                 ~5
          8        SEND_REF                                                 !2
          9        DO_ICALL                                                 
   12    10        INIT_FCALL                                               'array_filter'
         11        SEND_VAR                                                 !2
         12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9busa%3A12%240'
   14    13        SEND_VAL                                                 ~7
         14        DO_ICALL                                         $8      
   12    15        ASSIGN                                                   !2, $8
   17    16        INIT_FCALL                                               'asort'
         17        SEND_REF                                                 !2
         18        DO_ICALL                                                 
   20    19        FETCH_DIM_R                                      ~12     !1, 'path'
         20        ASSIGN_DIM                                               !2, 'url'
         21        OP_DATA                                                  ~12
   22    22        FETCH_DIM_R                                      ~13     !1, 'scheme'
         23        CONCAT                                           ~14     ~13, '%3A%2F%2F'
         24        FETCH_DIM_R                                      ~15     !1, 'host'
         25        CONCAT                                           ~16     ~14, ~15
         26        CONCAT                                           ~17     ~16, '%2F%3F'
         27        INIT_FCALL                                               'http_build_query'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $18     
         30        CONCAT                                           ~19     ~17, $18
         31      > RETURN                                                   ~19
   23    32*     > RETURN                                                   null

End of function parse

Function %00%7Bclosure%7D%2Fin%2F9busa%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9busa
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        CAST                                          4  ~1      !0
          2        IS_NOT_IDENTICAL                                 ~2      ~1, 3
          3      > RETURN                                                   ~2
   14     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9busa%3A12%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.09 ms | 1403 KiB | 24 Q