3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseIt($input){ parse_str(preg_replace ("/\s+(\w+\[?\]?)=/", "&$1=", $input), $output); $return = []; foreach ($output as $key => $value){ $value = preg_replace('/^"(.+)"$/', "$1", $value); $return[$key] = $value; } return $return; } $inputs[] = 'i=prd33 foo="really long value"'; $inputs[] = '1=prd33,prd22,prd44 foo="something " else with internal quotes"'; $inputs[] = '1=prd33,prd22,prd44 foo="something \' else with internal quotes\'"'; $inputs[] = 'i[]=prd33 foo="hah" i[]=prd32 bar="neener" i[]=prd31'; foreach ($inputs as $input){ print_r(parseIt($input)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/IWCtj
function name:  (null)
number of ops:  19
compiled vars:  !0 = $inputs, !1 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN_DIM                                               !0
          1        OP_DATA                                                  'i%3Dprd33+foo%3D%22really+long+value%22'
   14     2        ASSIGN_DIM                                               !0
          3        OP_DATA                                                  '1%3Dprd33%2Cprd22%2Cprd44+foo%3D%22something+%22+else+with+internal+quotes%22'
   15     4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  '1%3Dprd33%2Cprd22%2Cprd44+foo%3D%22something+%27+else+with+internal+quotes%27%22'
   16     6        ASSIGN_DIM                                               !0
          7        OP_DATA                                                  'i%5B%5D%3Dprd33+foo%3D%22hah%22+i%5B%5D%3Dprd32+bar%3D%22neener%22+i%5B%5D%3Dprd31'
   18     8      > FE_RESET_R                                       $6      !0, ->17
          9    > > FE_FETCH_R                                               $6, !1, ->17
   19    10    >   INIT_FCALL                                               'print_r'
         11        INIT_FCALL                                               'parseit'
         12        SEND_VAR                                                 !1
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   18    16      > JMP                                                      ->9
         17    >   FE_FREE                                                  $6
   20    18      > RETURN                                                   1

Function parseit:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 23
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/IWCtj
function name:  parseIt
number of ops:  26
compiled vars:  !0 = $input, !1 = $output, !2 = $return, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'parse_str'
          2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%5Cs%2B%28%5Cw%2B%5C%5B%3F%5C%5D%3F%29%3D%2F'
          4        SEND_VAL                                                 '%26%241%3D'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        SEND_VAR                                                 $5
          8        SEND_REF                                                 !1
          9        DO_ICALL                                                 
    5    10        ASSIGN                                                   !2, <array>
    6    11      > FE_RESET_R                                       $8      !1, ->23
         12    > > FE_FETCH_R                                       ~9      $8, !3, ->23
         13    >   ASSIGN                                                   !4, ~9
    7    14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%5E%22%28.%2B%29%22%24%2F'
         16        SEND_VAL                                                 '%241'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                         $11     
         19        ASSIGN                                                   !3, $11
    8    20        ASSIGN_DIM                                               !2, !4
         21        OP_DATA                                                  !3
    6    22      > JMP                                                      ->12
         23    >   FE_FREE                                                  $8
   10    24      > RETURN                                                   !2
   11    25*     > RETURN                                                   null

End of function parseit

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.79 ms | 1403 KiB | 20 Q