3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = '[_wc_acof_6] i want to convert'; $replacements = ['6' => 'NEW_VALUE_FOR_6_KEY']; echo preg_replace_callback('~\[_wc_acof_(\d+)]~', function($m) use ($replacements){ return $replacements[$m[1]]; }, $text);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pgZOY
function name:  (null)
number of ops:  11
compiled vars:  !0 = $text, !1 = $replacements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B_wc_acof_6%5D+i+want+to+convert'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%7E%5C%5B_wc_acof_%28%5Cd%2B%29%5D%7E'
          4        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
          5        BIND_LEXICAL                                             ~4, !1
    7     6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !0
    5     8        DO_ICALL                                         $5      
    7     9        ECHO                                                     $5
         10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pgZOY
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $m, !1 = $replacements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    6     2        FETCH_DIM_R                                      ~2      !0, 1
          3        FETCH_DIM_R                                      ~3      !1, ~2
          4      > RETURN                                                   ~3
    7     5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.92 ms | 1004 KiB | 14 Q