3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myArray = ['yellow', 'green']; $myString = 'banana is ?, apple is ?, lemon is ?, tomato is ?'; $count = count($myArray); $i = 0; while (($pos = strpos($myString, '?')) !== false) { $myString = substr_replace( $myString, $myArray[$i++ % $count], $pos, 1 ); } echo $myString;
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 = 23, Position 2 = 6
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 6
Branch analysis from position: 23
Branch analysis from position: 6
filename:       /in/LsJBH
function name:  (null)
number of ops:  25
compiled vars:  !0 = $myArray, !1 = $myString, !2 = $count, !3 = $i, !4 = $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+lemon+is+%3F%2C+tomato+is+%3F'
    7     2        COUNT                                            ~7      !0
          3        ASSIGN                                                   !2, ~7
    8     4        ASSIGN                                                   !3, 0
    9     5      > JMP                                                      ->16
   10     6    >   INIT_FCALL                                               'substr_replace'
   11     7        SEND_VAR                                                 !1
   12     8        POST_INC                                         ~10     !3
          9        MOD                                              ~11     ~10, !2
         10        FETCH_DIM_R                                      ~12     !0, ~11
         11        SEND_VAL                                                 ~12
   13    12        SEND_VAR                                                 !4
   14    13        SEND_VAL                                                 1
   10    14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !1, $13
    9    16    >   INIT_FCALL                                               'strpos'
         17        SEND_VAR                                                 !1
         18        SEND_VAL                                                 '%3F'
         19        DO_ICALL                                         $15     
         20        ASSIGN                                           ~16     !4, $15
         21        TYPE_CHECK                                  1018          ~16
         22      > JMPNZ                                                    ~17, ->6
   17    23    >   ECHO                                                     !1
   18    24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.21 ms | 1001 KiB | 15 Q