3v4l.org

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.31 ms | 1400 KiB | 21 Q