3v4l.org

run code in 500+ PHP versions simultaneously
<?php $searchData = ['%browser%', '%os%', '%city%']; $replaceData = ['Chrome', 'Windows', 'Delhi']; $str = 'When i work in %city% i was given with a laptop with %os% installed and it came with %browser%. everyone used `same %browser%` in our office.'; $rep = array_combine($searchData, $replaceData); $pattern = '~`[^`]*`(*SKIP)(*F)|' . implode('|', $searchData) . '~'; $result = preg_replace_callback($pattern, fn($m) => $rep[$m[0]], $str); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dED9P
function name:  (null)
number of ops:  22
compiled vars:  !0 = $searchData, !1 = $replaceData, !2 = $str, !3 = $rep, !4 = $pattern, !5 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
    5     2        ASSIGN                                                       !2, 'When+i+work+in+%25city%25+i+was+given+with+a+laptop+with+%25os%25+installed+and+it+came+with+%25browser%25.+everyone+used+%60same+%25browser%25%60+in+our+office.'
    7     3        INIT_FCALL                                                   'array_combine'
          4        SEND_VAR                                                     !0
          5        SEND_VAR                                                     !1
          6        DO_ICALL                                             $9      
          7        ASSIGN                                                       !3, $9
    8     8        FRAMELESS_ICALL_2                implode             ~11     '%7C', !0
          9        CONCAT                                               ~12     '%7E%60%5B%5E%60%5D%2A%60%28%2ASKIP%29%28%2AF%29%7C', ~11
         10        CONCAT                                               ~13     ~12, '%7E'
         11        ASSIGN                                                       !4, ~13
   10    12        INIT_FCALL                                                   'preg_replace_callback'
         13        SEND_VAR                                                     !4
         14        DECLARE_LAMBDA_FUNCTION                              ~15     [0]
         15        BIND_LEXICAL                                                 ~15, !3
         16        SEND_VAL                                                     ~15
         17        SEND_VAR                                                     !2
         18        DO_ICALL                                             $16     
         19        ASSIGN                                                       !5, $16
   12    20        ECHO                                                         !5
   13    21      > 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/dED9P
function name:  {closure:/in/dED9P:10}
number of ops:  6
compiled vars:  !0 = $m, !1 = $rep
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        FETCH_DIM_R                                          ~2      !0, 0
          3        FETCH_DIM_R                                          ~3      !1, ~2
          4      > RETURN                                                       ~3
          5*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.21 ms | 2068 KiB | 15 Q