3v4l.org

run code in 300+ PHP versions simultaneously
<?php function AttrFromString($string) { preg_match_all('/(\S+)=["\']?((?:.(?!["\']?\s+(?:\S+)=|[>"\']))+.)["\']?|(\S+)/', $string, $matches); $items = explode(" ", $string); $newlist = array(); foreach($items as $yes) { if (strpos($yes, "=")!==false) { $as = explode('=', $yes); } else { $as[0] = $yes; $as[1] = ""; } if (substr($as[1], 0,1) == "'" || substr($as[1], 0,1) == '"') { $as[1] = substr($as[1],1,strlen($as[1])-2); } array_push($newlist, array($as[0]. $as[1])); } 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/8ManF
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     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
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 67
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 67
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 47) Position 1 = 38, Position 2 = 46
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 58
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 58
Branch analysis from position: 46
Branch analysis from position: 26
2 jumps found. (Code = 47) Position 1 = 38, Position 2 = 46
Branch analysis from position: 38
Branch analysis from position: 46
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
filename:       /in/8ManF
function name:  AttrFromString
number of ops:  72
compiled vars:  !0 = $string, !1 = $matches, !2 = $items, !3 = $newlist, !4 = $yes, !5 = $as
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        INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '+'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !2, $7
    5    11        ASSIGN                                                   !3, <array>
    6    12      > FE_RESET_R                                       $10     !2, ->67
         13    > > FE_FETCH_R                                               $10, !4, ->67
    7    14    >   INIT_FCALL                                               'strpos'
         15        SEND_VAR                                                 !4
         16        SEND_VAL                                                 '%3D'
         17        DO_ICALL                                         $11     
         18        TYPE_CHECK                                  1018          $11
         19      > JMPZ                                                     ~12, ->26
    8    20    >   INIT_FCALL                                               'explode'
         21        SEND_VAL                                                 '%3D'
         22        SEND_VAR                                                 !4
         23        DO_ICALL                                         $13     
         24        ASSIGN                                                   !5, $13
         25      > JMP                                                      ->30
   11    26    >   ASSIGN_DIM                                               !5, 0
         27        OP_DATA                                                  !4
   12    28        ASSIGN_DIM                                               !5, 1
         29        OP_DATA                                                  ''
   14    30    >   INIT_FCALL                                               'substr'
         31        FETCH_DIM_R                                      ~17     !5, 1
         32        SEND_VAL                                                 ~17
         33        SEND_VAL                                                 0
         34        SEND_VAL                                                 1
         35        DO_ICALL                                         $18     
         36        IS_EQUAL                                         ~19     $18, '%27'
         37      > JMPNZ_EX                                         ~19     ~19, ->46
         38    >   INIT_FCALL                                               'substr'
         39        FETCH_DIM_R                                      ~20     !5, 1
         40        SEND_VAL                                                 ~20
         41        SEND_VAL                                                 0
         42        SEND_VAL                                                 1
         43        DO_ICALL                                         $21     
         44        IS_EQUAL                                         ~22     $21, '%22'
         45        BOOL                                             ~19     ~22
         46    > > JMPZ                                                     ~19, ->58
   15    47    >   INIT_FCALL                                               'substr'
         48        FETCH_DIM_R                                      ~24     !5, 1
         49        SEND_VAL                                                 ~24
         50        SEND_VAL                                                 1
         51        FETCH_DIM_R                                      ~25     !5, 1
         52        STRLEN                                           ~26     ~25
         53        SUB                                              ~27     ~26, 2
         54        SEND_VAL                                                 ~27
         55        DO_ICALL                                         $28     
         56        ASSIGN_DIM                                               !5, 1
         57        OP_DATA                                                  $28
   17    58    >   INIT_FCALL                                               'array_push'
         59        SEND_REF                                                 !3
         60        FETCH_DIM_R                                      ~29     !5, 0
         61        FETCH_DIM_R                                      ~30     !5, 1
         62        CONCAT                                           ~31     ~29, ~30
         63        INIT_ARRAY                                       ~32     ~31
         64        SEND_VAL                                                 ~32
         65        DO_ICALL                                                 
    6    66      > JMP                                                      ->13
         67    >   FE_FREE                                                  $10
   19    68        INIT_FCALL                                               'var_dump'
         69        SEND_VAR                                                 !3
         70        DO_ICALL                                                 
   20    71      > RETURN                                                   null

End of function attrfromstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.05 ms | 1407 KiB | 26 Q