3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = ['yellow', 'green', 'red']; $myString = 'banana is ?, apple is ?, tomato is ?'; $i = 0; while (($pos = strpos($myString, '?')) !== false) { $myString = substr_replace( $myString, $myArray[$i++], $pos, 1 ); } echo $myString;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 4
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 4
Branch analysis from position: 20
Branch analysis from position: 4
filename:       /in/9X4b2
function name:  (null)
number of ops:  22
compiled vars:  !0 = $myArray, !1 = $myString, !2 = $i, !3 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 'banana+is+%3F%2C+apple+is+%3F%2C+tomato+is+%3F'
    7     2        ASSIGN                                                   !2, 0
    8     3      > JMP                                                      ->13
    9     4    >   INIT_FCALL                                               'substr_replace'
   10     5        SEND_VAR                                                 !1
   11     6        POST_INC                                         ~7      !2
          7        FETCH_DIM_R                                      ~8      !0, ~7
          8        SEND_VAL                                                 ~8
   12     9        SEND_VAR                                                 !3
   13    10        SEND_VAL                                                 1
    9    11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !1, $9
    8    13    >   INIT_FCALL                                               'strpos'
         14        SEND_VAR                                                 !1
         15        SEND_VAL                                                 '%3F'
         16        DO_ICALL                                         $11     
         17        ASSIGN                                           ~12     !3, $11
         18        TYPE_CHECK                                  1018          ~12
         19      > JMPNZ                                                    ~13, ->4
   16    20    >   ECHO                                                     !1
   17    21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
131.78 ms | 1001 KiB | 15 Q