3v4l.org

run code in 500+ PHP versions simultaneously
<?php $re = '/\$\w+\K(?|\h*(\[)\h*(\'[^\']+\')\h*|(\h*\[)\h*("[^"]+")\h*)(?=])/m'; $str = '$foo [ "bar" ], $foo ["bar" ], $foo [ "bar"] $foo [ \'bar\' ], $foo [\'bar\' ], $foo [ \'bar\'] $foo [ \'this is different\' ]'; $result = preg_replace($re, '$1$2', $str); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/naVET
function name:  (null)
number of ops:  7
compiled vars:  !0 = $re, !1 = $str, !2 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%2F%5C%24%5Cw%2B%5CK%28%3F%7C%5Ch%2A%28%5C%5B%29%5Ch%2A%28%27%5B%5E%27%5D%2B%27%29%5Ch%2A%7C%28%5Ch%2A%5C%5B%29%5Ch%2A%28%22%5B%5E%22%5D%2B%22%29%5Ch%2A%29%28%3F%3D%5D%29%2Fm'
    4     1        ASSIGN                                                       !1, '%24foo+%5B+%22bar%22+%5D%2C+%24foo+%5B%22bar%22+%5D%2C+%24foo+%5B+%22bar%22%5D%0A%24foo+%5B+%27bar%27+%5D%2C+%24foo+%5B%27bar%27+%5D%2C+%24foo+%5B+%27bar%27%5D%0A%24foo+%5B+%27this+is+different%27+%5D'
    8     2        FRAMELESS_ICALL_3                preg_replace        ~5      !0, '%241%242'
          3        OP_DATA                                                      !1
          4        ASSIGN                                                       !2, ~5
   10     5        ECHO                                                         !2
   11     6      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
127.51 ms | 474 KiB | 7 Q