3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "some text here [baz] and here [you|him|her|foo|bar|baz|foo|option|test] and even here [another]."; // Capture strings between brackets preg_match_all('~\[([^]]+)]~', $string, $matches); $groups = []; foreach ($matches[1] as $values) { // Explode them on pipe $groups[] = explode('|', $values); } print_r($groups);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/LNKNj
function name:  (null)
number of ops:  22
compiled vars:  !0 = $string, !1 = $matches, !2 = $groups, !3 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'some+text+here+%5Bbaz%5D+and+here+%5Byou%7Chim%7Cher%7Cfoo%7Cbar%7Cbaz%7Cfoo%7Coption%7Ctest%5D+and+even+here+%5Banother%5D.'
    6     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%7E%5C%5B%28%5B%5E%5D%5D%2B%29%5D%7E'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    8     6        ASSIGN                                                   !2, <array>
   10     7        FETCH_DIM_R                                      ~7      !1, 1
          8      > FE_RESET_R                                       $8      ~7, ->17
          9    > > FE_FETCH_R                                               $8, !3, ->17
   12    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '%7C'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $10     
         14        ASSIGN_DIM                                               !2
         15        OP_DATA                                                  $10
   10    16      > JMP                                                      ->9
         17    >   FE_FREE                                                  $8
   15    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.1 ms | 1012 KiB | 16 Q