3v4l.org

run code in 300+ PHP versions simultaneously
<?php $s = '[specs product="test" category="body"]'; $pattern = '/(?:\[(?=[^][]*])(\w+)|\G(?!^))\h+(\w+)="([^"]+)"/'; $strings = [ '[specs product="test" category="body"]', '[pricelist keyword="216"]', '[specs product="test2" category="network" key="value"]' ]; foreach($strings as $s) { if (preg_match_all($pattern, $s, $matches)) { unset($matches[0]); $matches = array_map('array_filter', $matches); print_r($matches); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/RdRro
function name:  (null)
number of ops:  23
compiled vars:  !0 = $s, !1 = $pattern, !2 = $strings, !3 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5Bspecs+product%3D%22test%22+category%3D%22body%22%5D'
    4     1        ASSIGN                                                   !1, '%2F%28%3F%3A%5C%5B%28%3F%3D%5B%5E%5D%5B%5D%2A%5D%29%28%5Cw%2B%29%7C%5CG%28%3F%21%5E%29%29%5Ch%2B%28%5Cw%2B%29%3D%22%28%5B%5E%22%5D%2B%29%22%2F'
    6     2        ASSIGN                                                   !2, <array>
   12     3      > FE_RESET_R                                       $7      !2, ->21
          4    > > FE_FETCH_R                                               $7, !0, ->21
   13     5    >   INIT_FCALL                                               'preg_match_all'
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !0
          8        SEND_REF                                                 !3
          9        DO_ICALL                                         $8      
         10      > JMPZ                                                     $8, ->20
   14    11    >   UNSET_DIM                                                !3, 0
   15    12        INIT_FCALL                                               'array_map'
         13        SEND_VAL                                                 'array_filter'
         14        SEND_VAR                                                 !3
         15        DO_ICALL                                         $9      
         16        ASSIGN                                                   !3, $9
   16    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                                 
   12    20    > > JMP                                                      ->4
         21    >   FE_FREE                                                  $7
   18    22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.36 ms | 1000 KiB | 16 Q