3v4l.org

run code in 500+ 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:  12
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        FRAMELESS_ICALL_3                str_replace         ~3      '+', '%7C'
          3        OP_DATA                                                      !1
          4        ASSIGN                                                       !2, ~3
    4     5        ROPE_INIT                                         3  ~6      '%2F%5Cb%28%3F%3A'
          6        ROPE_ADD                                          1  ~6      ~6, !2
          7        ROPE_END                                          2  ~5      ~6, '%29%5Cb%5CK%2Fi'
          8        FRAMELESS_ICALL_3                preg_replace        ~8      ~5, '%3C-'
          9        OP_DATA                                                      !0
         10      > RETURN                                                       ~8
    5    11*     > RETURN                                                       null

End of function my_replace

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.99 ms | 2217 KiB | 14 Q