3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = 'The refugee said "dam!"'; $bad_words = array("fug","schnitt","dam"); $bad_words = array_walk($bad_words, function(&$value, $key) { // this prepares the regex, requires PHP 5.3+ I think. $value = preg_quote('~\b' . $value . '\b~i'); // \b means word boundary, like space, line-break, and I think period, dash, and many others. Prevends "refudgee" from being matched when searching for "fudge" }); $good_words = array("fudge","shoot","dang"); $good_text = preg_replace($bad_words,$good_words,$text);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A76VB
function name:  (null)
number of ops:  16
compiled vars:  !0 = $text, !1 = $bad_words, !2 = $good_words, !3 = $good_text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'The+refugee+said+%22dam%21%22'
    5     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'array_walk'
          3        SEND_REF                                                 !1
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FA76VB%3A6%240'
    8     5        SEND_VAL                                                 ~6
          6        DO_ICALL                                         $7      
    6     7        ASSIGN                                                   !1, $7
   10     8        ASSIGN                                                   !2, <array>
   12     9        INIT_FCALL                                               'preg_replace'
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !3, $10
         15      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FA76VB%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A76VB
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'preg_quote'
          3        CONCAT                                           ~2      '%7E%5Cb', !0
          4        CONCAT                                           ~3      ~2, '%5Cb%7Ei'
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !0, $4
    8     8      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FA76VB%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.6 ms | 1395 KiB | 19 Q