3v4l.org

run code in 500+ 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'; if (preg_match_all('~\[_wc_acof_(\d+)]~', $text, $matches)) { print_r($matches[1]); $replacements = [ '6' => 'NEW_VALUE_FOR_6_KEY', '9' => 'NEW_VALUE_FOR_9_KEY', '11' => 'NEW_VALUE_FOR_11_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
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/MTvYF
function name:  (null)
number of ops:  21
compiled vars:  !0 = $text, !1 = $matches, !2 = $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        INIT_FCALL                                                   'preg_match_all'
          2        SEND_VAL                                                     '%7E%5C%5B_wc_acof_%28%5Cd%2B%29%5D%7E'
          3        SEND_VAR                                                     !0
          4        SEND_REF                                                     !1
          5        DO_ICALL                                             $4      
          6      > JMPZ                                                         $4, ->20
    5     7    >   INIT_FCALL                                                   'print_r'
          8        FETCH_DIM_R                                          ~5      !1, 1
          9        SEND_VAL                                                     ~5
         10        DO_ICALL                                                     
    6    11        ASSIGN                                                       !2, <array>
   11    12        INIT_FCALL                                                   'preg_replace_callback'
         13        SEND_VAL                                                     '%7E%5C%5B_wc_acof_%28%5Cd%2B%29%5D%7E'
         14        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
         15        BIND_LEXICAL                                                 ~8, !2
   13    16        SEND_VAL                                                     ~8
         17        SEND_VAR                                                     !0
   11    18        DO_ICALL                                             $9      
   13    19        ECHO                                                         $9
   14    20    > > 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/MTvYF
function name:  {closure:/in/MTvYF:11}
number of ops:  6
compiled vars:  !0 = $m, !1 = $replacements
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   12     2        FETCH_DIM_R                                          ~2      !0, 1
          3        FETCH_DIM_R                                          ~3      !1, ~2
          4      > RETURN                                                       ~3
   13     5*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.94 ms | 2046 KiB | 16 Q