3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['foo' => [5 => 'bar', 10 => 'baz']]; $match = 'foo.{key}.bar'; $pattern = '/'.preg_replace('/\{(\w+?)\}/', '(.+)', str_replace('.', '\.', $match)).'/'; if (preg_match($pattern, $match, $matches)) { var_dump($matches); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 24
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/R0inL
function name:  (null)
number of ops:  25
compiled vars:  !0 = $arr, !1 = $match, !2 = $pattern, !3 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, 'foo.%7Bkey%7D.bar'
    5     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%5C%7B%28%5Cw%2B%3F%29%5C%7D%2F'
          4        SEND_VAL                                                 '%28.%2B%29'
          5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 '.'
          7        SEND_VAL                                                 '%5C.'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                         $7      
         12        CONCAT                                           ~8      '%2F', $7
         13        CONCAT                                           ~9      ~8, '%2F'
         14        ASSIGN                                                   !2, ~9
    6    15        INIT_FCALL                                               'preg_match'
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !1
         18        SEND_REF                                                 !3
         19        DO_ICALL                                         $11     
         20      > JMPZ                                                     $11, ->24
    7    21    >   INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                                 
    8    24    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.15 ms | 1395 KiB | 21 Q