3v4l.org

run code in 300+ PHP versions simultaneously
<?php function my_replace (string $fullText, string $searchText) { $searches = str_replace(' ', '|', $searchText); return preg_replace("/\b(?:$searches)\b\K/i", "<-", $fullText); } echo my_replace('A week ago, Elvis left the Building', 'elvis left');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XER39
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'my_replace'
          1        SEND_VAL                                                 'A+week+ago%2C+Elvis+left+the+Building'
          2        SEND_VAL                                                 'elvis+left'
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function my_replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XER39
function name:  my_replace
number of ops:  18
compiled vars:  !0 = $fullText, !1 = $searchText, !2 = $searches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '+'
          4        SEND_VAL                                                 '%7C'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !2, $3
    4     8        INIT_FCALL                                               'preg_replace'
          9        ROPE_INIT                                     3  ~6      '%2F%5Cb%28%3F%3A'
         10        ROPE_ADD                                      1  ~6      ~6, !2
         11        ROPE_END                                      2  ~5      ~6, '%29%5Cb%5CK%2Fi'
         12        SEND_VAL                                                 ~5
         13        SEND_VAL                                                 '%3C-'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $8      
         16      > RETURN                                                   $8
    5    17*     > RETURN                                                   null

End of function my_replace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.83 ms | 1014 KiB | 16 Q