3v4l.org

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

End of function attrfromstring

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
226.57 ms | 1407 KiB | 26 Q