3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = "GOODDAY"; $find = "O"; $replaceWith = "U"; $lastPos = 0; while (($lastPos = strpos($str, $find, $lastPos)) !== false) { echo substr_replace($str, $replaceWith, $lastPos, 1) . "\n"; $lastPos = $lastPos + strlen($find); } echo str_replace($find, $replaceWith, $str);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
Branch analysis from position: 5
filename:       /in/ddg73
function name:  (null)
number of ops:  25
compiled vars:  !0 = $str, !1 = $find, !2 = $replaceWith, !3 = $lastPos
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'GOODDAY'
    4     1        ASSIGN                                                       !1, 'O'
    5     2        ASSIGN                                                       !2, 'U'
    6     3        ASSIGN                                                       !3, 0
    8     4      > JMP                                                          ->16
    9     5    >   INIT_FCALL                                                   'substr_replace'
          6        SEND_VAR                                                     !0
          7        SEND_VAR                                                     !2
          8        SEND_VAR                                                     !3
          9        SEND_VAL                                                     1
         10        DO_ICALL                                             $8      
         11        CONCAT                                               ~9      $8, '%0A'
         12        ECHO                                                         ~9
   10    13        STRLEN                                               ~10     !1
         14        ADD                                                  ~11     !3, ~10
         15        ASSIGN                                                       !3, ~11
    8    16    >   FRAMELESS_ICALL_3                strpos              ~13     !0, !1
         17        OP_DATA                                                      !3
         18        ASSIGN                                               ~14     !3, ~13
         19        TYPE_CHECK                                      1018          ~14
         20      > JMPNZ                                                        ~15, ->5
   13    21    >   FRAMELESS_ICALL_3                str_replace         ~16     !1, !2
         22        OP_DATA                                                      !0
         23        ECHO                                                         ~16
         24      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
147.37 ms | 1986 KiB | 14 Q