3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = 'print the imprint with the imprinted printing paper'; $replacements = array( 'print' => 'imprint', 'imprint' => 'print', 'paper' => 'machine' ); $delimiter = '/'; $words = array_keys( $replacements); $regex = $delimiter . '\b(' . implode('|', array_map( 'preg_quote', $words, array_fill( 0, count( $words), $delimiter))) . ')\b' . $delimiter; $result = preg_replace_callback( $regex, function( $match) use( $replacements) { return $replacements[$match[1]]; }, $string); echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gb0pA
function name:  (null)
number of ops:  34
compiled vars:  !0 = $string, !1 = $replacements, !2 = $delimiter, !3 = $words, !4 = $regex, !5 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 'print+the+imprint+with+the+imprinted+printing+paper'
    4     1        ASSIGN                                                       !1, <array>
   10     2        ASSIGN                                                       !2, '%2F'
   11     3        INIT_FCALL                                                   'array_keys'
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $9      
          6        ASSIGN                                                       !3, $9
   12     7        CONCAT                                               ~11     !2, '%5Cb%28'
          8        INIT_FCALL                                                   'array_map'
          9        SEND_VAL                                                     'preg_quote'
         10        SEND_VAR                                                     !3
         11        INIT_FCALL                                                   'array_fill'
         12        SEND_VAL                                                     0
         13        COUNT                                                ~12     !3
         14        SEND_VAL                                                     ~12
         15        SEND_VAR                                                     !2
         16        DO_ICALL                                             $13     
         17        SEND_VAR                                                     $13
         18        DO_ICALL                                             $14     
         19        FRAMELESS_ICALL_2                implode             ~15     '%7C', $14
         20        CONCAT                                               ~16     ~11, ~15
         21        CONCAT                                               ~17     ~16, '%29%5Cb'
         22        CONCAT                                               ~18     ~17, !2
         23        ASSIGN                                                       !4, ~18
   14    24        INIT_FCALL                                                   'preg_replace_callback'
         25        SEND_VAR                                                     !4
         26        DECLARE_LAMBDA_FUNCTION                              ~20     [0]
         27        BIND_LEXICAL                                                 ~20, !1
   16    28        SEND_VAL                                                     ~20
         29        SEND_VAR                                                     !0
   14    30        DO_ICALL                                             $21     
         31        ASSIGN                                                       !5, $21
   17    32        ECHO                                                         !5
         33      > 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/gb0pA
function name:  {closure:/in/gb0pA:14}
number of ops:  6
compiled vars:  !0 = $match, !1 = $replacements
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
   15     2        FETCH_DIM_R                                          ~2      !0, 1
          3        FETCH_DIM_R                                          ~3      !1, ~2
          4      > RETURN                                                       ~3
   16     5*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.15 ms | 2644 KiB | 17 Q