3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '100% Pure Body Butters French Lavender 3.4 fl. Oz'; $replacements = array( 'oz' => '', 'Oz' => '', ); $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/vYshV
function name:  (null)
number of ops:  37
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, '100%25+Pure+Body+Butters+French+Lavender+3.4+fl.+Oz'
    4     1        ASSIGN                                                   !1, <array>
    9     2        ASSIGN                                                   !2, '%2F'
   10     3        INIT_FCALL                                               'array_keys'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !3, $9
   11     7        CONCAT                                           ~11     !2, '%5Cb%28'
          8        INIT_FCALL                                               'implode'
          9        SEND_VAL                                                 '%7C'
         10        INIT_FCALL                                               'array_map'
         11        SEND_VAL                                                 'preg_quote'
         12        SEND_VAR                                                 !3
         13        INIT_FCALL                                               'array_fill'
         14        SEND_VAL                                                 0
         15        COUNT                                            ~12     !3
         16        SEND_VAL                                                 ~12
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $13     
         19        SEND_VAR                                                 $13
         20        DO_ICALL                                         $14     
         21        SEND_VAR                                                 $14
         22        DO_ICALL                                         $15     
         23        CONCAT                                           ~16     ~11, $15
         24        CONCAT                                           ~17     ~16, '%29%5Cb'
         25        CONCAT                                           ~18     ~17, !2
         26        ASSIGN                                                   !4, ~18
   13    27        INIT_FCALL                                               'preg_replace_callback'
         28        SEND_VAR                                                 !4
         29        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvYshV%3A13%240'
         30        BIND_LEXICAL                                             ~20, !1
   15    31        SEND_VAL                                                 ~20
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                         $21     
   13    34        ASSIGN                                                   !5, $21
   16    35        ECHO                                                     !5
         36      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvYshV%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vYshV
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $match, !1 = $replacements
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   14     2        FETCH_DIM_R                                      ~2      !0, 1
          3        FETCH_DIM_R                                      ~3      !1, ~2
          4      > RETURN                                                   ~3
   15     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvYshV%3A13%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.58 ms | 1400 KiB | 23 Q