3v4l.org

run code in 300+ PHP versions simultaneously
<?php $commands = array("mark", "ignore", "pick", "random"); $attempts = array("mark", "ignore", "pick", "random", "bonk"); foreach($attempts as $attempt){ echo "$attempt => "; $index=array_search($attempt,$commands); if($index===false || !isset($commands[++$index])){ // not found or found last element $index=0; // use first element } echo $commands[$index],"\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 18
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/oi2Lp
function name:  (null)
number of ops:  26
compiled vars:  !0 = $commands, !1 = $attempts, !2 = $attempt, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $6      !1, ->24
          3    > > FE_FETCH_R                                               $6, !2, ->24
    6     4    >   NOP                                                      
          5        FAST_CONCAT                                      ~7      !2, '+%3D%3E+'
          6        ECHO                                                     ~7
    7     7        INIT_FCALL                                               'array_search'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !3, $8
    8    12        TYPE_CHECK                                    4  ~10     !3
         13      > JMPNZ_EX                                         ~10     ~10, ->18
         14    >   PRE_INC                                          ~11     !3
         15        ISSET_ISEMPTY_DIM_OBJ                         0  ~12     !0, ~11
         16        BOOL_NOT                                         ~13     ~12
         17        BOOL                                             ~10     ~13
         18    > > JMPZ                                                     ~10, ->20
    9    19    >   ASSIGN                                                   !3, 0
   11    20    >   FETCH_DIM_R                                      ~15     !0, !3
         21        ECHO                                                     ~15
         22        ECHO                                                     '%0A'
    5    23      > JMP                                                      ->3
         24    >   FE_FREE                                                  $6
   12    25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.18 ms | 1011 KiB | 14 Q