3v4l.org

run code in 300+ PHP versions simultaneously
<?php function AttrFromString($string) { preg_match_all('/(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>"\']))+.)["\']?|(\S+)/', $string, $matches); $newlist = array(); for($i = 0; $i < count($matches[0]); $i++) { if (!empty($matches[1][$i])) { array_push($newlist, array($matches[1][$i] , $matches[2][$i])); } else { if(!empty($matches[3][$i])) { array_push($newlist, array($matches[3][$i] , "")); } } } var_dump($newlist); } AttrFromString("test=hallo tes2=\"doei\" test3='lol' no-pe ja test='niks'");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iO7W3
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'attrfromstring'
          1        SEND_VAL                                                 'test%3Dhallo+tes2%3D%22doei%22+test3%3D%27lol%27+no-pe+ja+test%3D%27niks%27'
          2        DO_FCALL                                      0          
          3      > RETURN                                                   1

Function attrfromstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 9
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 9
Branch analysis from position: 41
Branch analysis from position: 9
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 36
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 9
Branch analysis from position: 41
Branch analysis from position: 9
Branch analysis from position: 36
filename:       /in/iO7W3
function name:  AttrFromString
number of ops:  45
compiled vars:  !0 = $string, !1 = $matches, !2 = $newlist, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%28%5CS%2B%29%3D%5B%22%27%5D%3F%28%28%3F%3A.%28%3F%21%5B%22%27%5D%3F%5Cs%2B%28%3F%3A%5CS%2B%29%3D%7C%5B%3E%22%27%5D%29%29%2B.%29%5B%22%27%5D%3F%7C%28%5CS%2B%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    4     6        ASSIGN                                                   !2, <array>
    5     7        ASSIGN                                                   !3, 0
          8      > JMP                                                      ->37
    6     9    >   FETCH_DIM_IS                                     ~7      !1, 1
         10        ISSET_ISEMPTY_DIM_OBJ                         1  ~8      ~7, !3
         11        BOOL_NOT                                         ~9      ~8
         12      > JMPZ                                                     ~9, ->24
    7    13    >   INIT_FCALL                                               'array_push'
         14        SEND_REF                                                 !2
         15        FETCH_DIM_R                                      ~10     !1, 1
         16        FETCH_DIM_R                                      ~11     ~10, !3
         17        INIT_ARRAY                                       ~12     ~11
         18        FETCH_DIM_R                                      ~13     !1, 2
         19        FETCH_DIM_R                                      ~14     ~13, !3
         20        ADD_ARRAY_ELEMENT                                ~12     ~14
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                                 
         23      > JMP                                                      ->36
   10    24    >   FETCH_DIM_IS                                     ~16     !1, 3
         25        ISSET_ISEMPTY_DIM_OBJ                         1  ~17     ~16, !3
         26        BOOL_NOT                                         ~18     ~17
         27      > JMPZ                                                     ~18, ->36
   11    28    >   INIT_FCALL                                               'array_push'
         29        SEND_REF                                                 !2
         30        FETCH_DIM_R                                      ~19     !1, 3
         31        FETCH_DIM_R                                      ~20     ~19, !3
         32        INIT_ARRAY                                       ~21     ~20
         33        ADD_ARRAY_ELEMENT                                ~21     ''
         34        SEND_VAL                                                 ~21
         35        DO_ICALL                                                 
    5    36    >   PRE_INC                                                  !3
         37    >   FETCH_DIM_R                                      ~24     !1, 0
         38        COUNT                                            ~25     ~24
         39        IS_SMALLER                                               !3, ~25
         40      > JMPNZ                                                    ~26, ->9
   16    41    >   INIT_FCALL                                               'var_dump'
         42        SEND_VAR                                                 !2
         43        DO_ICALL                                                 
   17    44      > RETURN                                                   null

End of function attrfromstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.78 ms | 1407 KiB | 20 Q