3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseQueryString($str) { $result = []; foreach (explode('&', $str) as $element) { $parts = explode('=', $element, 2); $key = urldecode(array_shift($parts)); $value = $parts ? urldecode(array_shift($parts)) : ''; if (false !== $pos = strpos($key, '[')) { $base = substr($result, $key, 0, $pos++); $result[$base] = []; $target = &$result[$base]; do { $end = strpos($key, ']', $pos); $index = substr($key, $pos, $end - $pos); $target[$index] = []; $target = &$target[$index]; $pos = $end; } while($pos < strlen($key)); var_dump($result); } } } $str = 'foo=bar&baz[foo]=qux&baz[foo][goat]=chick'; parseQueryString($str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/J5tul
function name:  (null)
number of ops:  5
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   ASSIGN                                                   !0, 'foo%3Dbar%26baz%5Bfoo%5D%3Dqux%26baz%5Bfoo%5D%5Bgoat%5D%3Dchick'
   31     1        INIT_FCALL                                               'parsequerystring'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function parsequerystring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 76
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 76
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 75
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 51
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 51
Branch analysis from position: 75
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 75
Branch analysis from position: 39
Branch analysis from position: 75
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
filename:       /in/J5tul
function name:  parseQueryString
number of ops:  78
compiled vars:  !0 = $str, !1 = $result, !2 = $element, !3 = $parts, !4 = $key, !5 = $value, !6 = $pos, !7 = $base, !8 = $target, !9 = $end, !10 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    7     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%26'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $12     
          6      > FE_RESET_R                                       $13     $12, ->76
          7    > > FE_FETCH_R                                               $13, !2, ->76
    8     8    >   INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%3D'
         10        SEND_VAR                                                 !2
         11        SEND_VAL                                                 2
         12        DO_ICALL                                         $14     
         13        ASSIGN                                                   !3, $14
    9    14        INIT_FCALL                                               'urldecode'
         15        INIT_FCALL                                               'array_shift'
         16        SEND_REF                                                 !3
         17        DO_ICALL                                         $16     
         18        SEND_VAR                                                 $16
         19        DO_ICALL                                         $17     
         20        ASSIGN                                                   !4, $17
   10    21      > JMPZ                                                     !3, ->30
         22    >   INIT_FCALL                                               'urldecode'
         23        INIT_FCALL                                               'array_shift'
         24        SEND_REF                                                 !3
         25        DO_ICALL                                         $19     
         26        SEND_VAR                                                 $19
         27        DO_ICALL                                         $20     
         28        QM_ASSIGN                                        ~21     $20
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~21     ''
         31    >   ASSIGN                                                   !5, ~21
   12    32        INIT_FCALL                                               'strpos'
         33        SEND_VAR                                                 !4
         34        SEND_VAL                                                 '%5B'
         35        DO_ICALL                                         $23     
         36        ASSIGN                                           ~24     !6, $23
         37        TYPE_CHECK                                  1018          ~24
         38      > JMPZ                                                     ~25, ->75
   13    39    >   INIT_FCALL                                               'substr'
         40        SEND_VAR                                                 !1
         41        SEND_VAR                                                 !4
         42        SEND_VAL                                                 0
         43        POST_INC                                         ~26     !6
         44        SEND_VAL                                                 ~26
         45        DO_ICALL                                         $27     
         46        ASSIGN                                                   !7, $27
   14    47        ASSIGN_DIM                                               !1, !7
         48        OP_DATA                                                  <array>
   15    49        FETCH_DIM_W                                      $30     !1, !7
         50        ASSIGN_REF                                               !8, $30
   18    51    >   INIT_FCALL                                               'strpos'
         52        SEND_VAR                                                 !4
         53        SEND_VAL                                                 '%5D'
         54        SEND_VAR                                                 !6
         55        DO_ICALL                                         $32     
         56        ASSIGN                                                   !9, $32
   19    57        INIT_FCALL                                               'substr'
         58        SEND_VAR                                                 !4
         59        SEND_VAR                                                 !6
         60        SUB                                              ~34     !9, !6
         61        SEND_VAL                                                 ~34
         62        DO_ICALL                                         $35     
         63        ASSIGN                                                   !10, $35
   20    64        ASSIGN_DIM                                               !8, !10
         65        OP_DATA                                                  <array>
   21    66        FETCH_DIM_W                                      $38     !8, !10
         67        ASSIGN_REF                                               !8, $38
   22    68        ASSIGN                                                   !6, !9
   23    69        STRLEN                                           ~41     !4
         70        IS_SMALLER                                               !6, ~41
         71      > JMPNZ                                                    ~42, ->51
   25    72    >   INIT_FCALL                                               'var_dump'
         73        SEND_VAR                                                 !1
         74        DO_ICALL                                                 
    7    75    > > JMP                                                      ->7
         76    >   FE_FREE                                                  $13
   28    77      > RETURN                                                   null

End of function parsequerystring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.03 ms | 1398 KiB | 26 Q