3v4l.org

run code in 500+ PHP versions simultaneously
<?php function my_replace(string $fullText, string $searchText){ $searches = explode(' ',$searchText); $replace = array(); foreach ($searches as $i => $search){ $position = strlen($search)+stripos($fullText, $search); $fullText = substr_replace($fullText, '<- ', $position, 0); } return $fullText; } echo my_replace('A week ago, Elvis left the Building', 'elvis left bonk');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TbOqp
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                                   'my_replace'
          1        SEND_VAL                                                     'A+week+ago%2C+Elvis+left+the+Building'
          2        SEND_VAL                                                     'elvis+left+bonk'
          3        DO_FCALL                                          0  $0      
          4        ECHO                                                         $0
          5      > RETURN                                                       1

Function my_replace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/TbOqp
function name:  my_replace
number of ops:  29
compiled vars:  !0 = $fullText, !1 = $searchText, !2 = $searches, !3 = $replace, !4 = $search, !5 = $i, !6 = $position
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    4     2        INIT_FCALL                                                   'explode'
          3        SEND_VAL                                                     '+'
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $7      
          6        ASSIGN                                                       !2, $7
    5     7        ASSIGN                                                       !3, <array>
    6     8      > FE_RESET_R                                           $10     !2, ->26
          9    > > FE_FETCH_R                                           ~11     $10, !4, ->26
         10    >   ASSIGN                                                       !5, ~11
    7    11        STRLEN                                               ~13     !4
         12        INIT_FCALL                                                   'stripos'
         13        SEND_VAR                                                     !0
         14        SEND_VAR                                                     !4
         15        DO_ICALL                                             $14     
         16        ADD                                                  ~15     ~13, $14
         17        ASSIGN                                                       !6, ~15
    8    18        INIT_FCALL                                                   'substr_replace'
         19        SEND_VAR                                                     !0
         20        SEND_VAL                                                     '%3C-+'
         21        SEND_VAR                                                     !6
         22        SEND_VAL                                                     0
         23        DO_ICALL                                             $17     
         24        ASSIGN                                                       !0, $17
    6    25      > JMP                                                          ->9
         26    >   FE_FREE                                                      $10
   11    27      > RETURN                                                       !0
   12    28*     > RETURN                                                       null

End of function my_replace

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.68 ms | 2227 KiB | 17 Q