3v4l.org

run code in 300+ PHP versions simultaneously
<?php preg_match_all( '#(?:\[link|(?!^)\G)\K(?:\s+([^=\s]+)=["\'](.*?)["\']|.*?\](.*?)\[/link\])#i', 'ops [link href="http://www.google.com"]www.google.com[/link]', $matches, PREG_SET_ORDER); $links = array(); $reset = true; foreach($matches as $match) { if($reset) { $links[] = array( 'params' => array(), 'value' => null ); $reset = false; } end($links); $key = key($links); if(isset($match[3])) { $links[$key]['value'] = $match[3]; $reset = true; } else { $links[$key]['params'][$match[1]] = $match[2]; } } print_r($links);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 36
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 36
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 14
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 14
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/jJFum
function name:  (null)
number of ops:  41
compiled vars:  !0 = $matches, !1 = $links, !2 = $reset, !3 = $match, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'preg_match_all'
    4     1        SEND_VAL                                                 '%23%28%3F%3A%5C%5Blink%7C%28%3F%21%5E%29%5CG%29%5CK%28%3F%3A%5Cs%2B%28%5B%5E%3D%5Cs%5D%2B%29%3D%5B%22%27%5D%28.%2A%3F%29%5B%22%27%5D%7C.%2A%3F%5C%5D%28.%2A%3F%29%5C%5B%2Flink%5C%5D%29%23i'
    5     2        SEND_VAL                                                 'ops+%5Blink+href%3D%22http%3A%2F%2Fwww.google.com%22%5Dwww.google.com%5B%2Flink%5D'
          3        SEND_REF                                                 !0
          4        SEND_VAL                                                 2
          5        DO_ICALL                                                 
    7     6        ASSIGN                                                   !1, <array>
    8     7        ASSIGN                                                   !2, <true>
   10     8      > FE_RESET_R                                       $8      !0, ->36
          9    > > FE_FETCH_R                                               $8, !3, ->36
   11    10    > > JMPZ                                                     !2, ->14
   12    11    >   ASSIGN_DIM                                               !1
   13    12        OP_DATA                                                  <array>
   17    13        ASSIGN                                                   !2, <false>
   20    14    >   INIT_FCALL                                               'end'
         15        SEND_REF                                                 !1
         16        DO_ICALL                                                 
   21    17        INIT_FCALL                                               'key'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $12     
         20        ASSIGN                                                   !4, $12
   23    21        ISSET_ISEMPTY_DIM_OBJ                         0          !3, 3
         22      > JMPZ                                                     ~14, ->29
   24    23    >   FETCH_DIM_R                                      ~17     !3, 3
         24        FETCH_DIM_W                                      $15     !1, !4
         25        ASSIGN_DIM                                               $15, 'value'
         26        OP_DATA                                                  ~17
   25    27        ASSIGN                                                   !2, <true>
         28      > JMP                                                      ->35
   27    29    >   FETCH_DIM_R                                      ~21     !3, 1
         30        FETCH_DIM_R                                      ~23     !3, 2
         31        FETCH_DIM_W                                      $19     !1, !4
         32        FETCH_DIM_W                                      $20     $19, 'params'
         33        ASSIGN_DIM                                               $20, ~21
         34        OP_DATA                                                  ~23
   10    35    > > JMP                                                      ->9
         36    >   FE_FREE                                                  $8
   31    37        INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
211.92 ms | 1400 KiB | 21 Q