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]."; $pattern = (function () use ($string) { $array = []; for ($i = 0; $i <= substr_count($string, "|"); $i++) { $array[] = $i == 0 ? '([^][|]+)' : '([^][|]+)?'; } return implode("\|?", $array); })(); preg_match_all("~\[$pattern]~", $string, $matches, PREG_SET_ORDER); var_dump($matches);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/isnnT
function name:  (null)
number of ops:  19
compiled vars:  !0 = $string, !1 = $pattern, !2 = $matches
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.'
    5     1        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          2        BIND_LEXICAL                                             ~4, !0
   11     3        INIT_DYNAMIC_CALL                                        ~4
          4        DO_FCALL                                      0  $5      
    5     5        ASSIGN                                                   !1, $5
   13     6        INIT_FCALL                                               'preg_match_all'
          7        ROPE_INIT                                     3  ~8      '%7E%5C%5B'
          8        ROPE_ADD                                      1  ~8      ~8, !1
          9        ROPE_END                                      2  ~7      ~8, '%5D%7E'
         10        SEND_VAL                                                 ~7
         11        SEND_VAR                                                 !0
         12        SEND_REF                                                 !2
         13        SEND_VAL                                                 2
         14        DO_ICALL                                                 
   15    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
         18      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
Branch analysis from position: 4
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 4
Branch analysis from position: 18
Branch analysis from position: 4
filename:       /in/isnnT
function name:  {closure}
number of ops:  24
compiled vars:  !0 = $string, !1 = $array, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
    6     1        ASSIGN                                                   !1, <array>
    7     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->12
    8     4    >   IS_EQUAL                                                 !2, 0
          5      > JMPZ                                                     ~6, ->8
          6    >   QM_ASSIGN                                        ~7      '%28%5B%5E%5D%5B%7C%5D%2B%29'
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~7      '%28%5B%5E%5D%5B%7C%5D%2B%29%3F'
          9    >   ASSIGN_DIM                                               !1
         10        OP_DATA                                                  ~7
    7    11        PRE_INC                                                  !2
         12    >   INIT_FCALL                                               'substr_count'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 '%7C'
         15        DO_ICALL                                         $9      
         16        IS_SMALLER_OR_EQUAL                                      !2, $9
         17      > JMPNZ                                                    ~10, ->4
   10    18    >   INIT_FCALL                                               'implode'
         19        SEND_VAL                                                 '%5C%7C%3F'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $11     
         22      > RETURN                                                   $11
   11    23*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.42 ms | 1006 KiB | 17 Q