3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "PHP [gallery-1]. [gallery-2]"; if (preg_match_all("/\bgallery-\b/i", $text, $matches, PREG_OFFSET_CAPTURE)) { // print_r($matches); $matches = $matches[0]; if(is_array($matches)) { foreach($matches as $match) { print_r($match); } } // $position = $matches[0][0][1]; } else { echo "A match was not found."; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 19
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8uLK4
function name:  (null)
number of ops:  22
compiled vars:  !0 = $text, !1 = $matches, !2 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'PHP+%5Bgallery-1%5D.+%5Bgallery-2%5D'
    5     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%5Cbgallery-%5Cb%2Fi'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        SEND_VAL                                                 256
          6        DO_ICALL                                         $4      
          7      > JMPZ                                                     $4, ->20
    8     8    >   FETCH_DIM_R                                      ~5      !1, 0
          9        ASSIGN                                                   !1, ~5
   10    10        TYPE_CHECK                                  128          !1
         11      > JMPZ                                                     ~7, ->19
   11    12    > > FE_RESET_R                                       $8      !1, ->18
         13    > > FE_FETCH_R                                               $8, !2, ->18
   12    14    >   INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
   11    17      > JMP                                                      ->13
         18    >   FE_FREE                                                  $8
         19    > > JMP                                                      ->21
   18    20    >   ECHO                                                     'A+match+was+not+found.'
   19    21    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.42 ms | 1400 KiB | 17 Q