3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = '[_wc_acof_6] i want to convert this and it contains also this [_wc_acof_9] or can be this [_wc_acof_11] number can never be static'; $replacements = [ '6' => 'NEW_VALUE_FOR_6_KEY', '9' => 'NEW_VALUE_FOR_9_KEY' ]; echo preg_replace_callback('~\[_wc_acof_(\d+)]~', function($m) use ($replacements){ return isset($replacements[$m[1]]) ? $replacements[$m[1]] : $m[0]; }, $text);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kP2eI
function name:  (null)
number of ops:  11
compiled vars:  !0 = $text, !1 = $replacements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%5B_wc_acof_6%5D+i+want+to+convert+this+and+it+contains+also+this+%5B_wc_acof_9%5D+or+can+be+this+%5B_wc_acof_11%5D+number+can+never+be+static'
    4     1        ASSIGN                                                   !1, <array>
    9     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
   11     6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !0
    9     8        DO_ICALL                                         $5      
   11     9        ECHO                                                     $5
         10      > RETURN                                                   1


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

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
268.78 ms | 1011 KiB | 14 Q