3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "PHP [gallery-1]. [gallery-2]"; echo preg_replace('/\[gallery-([1-9]*)\]/', '$1', $text); die(); 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) { $pos = $match[1]-1; } } // $position = $matches[0][0][1]; } else { echo "A match was not found."; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/A2Uch
function name:  (null)
number of ops:  29
compiled vars:  !0 = $text, !1 = $matches, !2 = $match, !3 = $pos
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_replace'
          2        SEND_VAL                                                 '%2F%5C%5Bgallery-%28%5B1-9%5D%2A%29%5C%5D%2F'
          3        SEND_VAL                                                 '%241'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ECHO                                                     $5
    7     7      > EXIT                                                     
    9     8*       INIT_FCALL                                               'preg_match_all'
          9*       SEND_VAL                                                 '%2F%5Cbgallery-%5Cb%2Fi'
         10*       SEND_VAR                                                 !0
         11*       SEND_REF                                                 !1
         12*       SEND_VAL                                                 256
         13*       DO_ICALL                                         $6      
         14*       JMPZ                                                     $6, ->27
   12    15*       FETCH_DIM_R                                      ~7      !1, 0
         16*       ASSIGN                                                   !1, ~7
   14    17*       TYPE_CHECK                                  128          !1
         18*       JMPZ                                                     ~9, ->26
   15    19*       FE_RESET_R                                       $10     !1, ->25
         20*       FE_FETCH_R                                               $10, !2, ->25
   16    21*       FETCH_DIM_R                                      ~11     !2, 1
         22*       SUB                                              ~12     ~11, 1
         23*       ASSIGN                                                   !3, ~12
   15    24*       JMP                                                      ->20
         25*       FE_FREE                                                  $10
         26*       JMP                                                      ->28
   22    27*       ECHO                                                     'A+match+was+not+found.'
   23    28*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.79 ms | 1395 KiB | 17 Q