3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(0,1,2); $maxtries = intval(count($a)*(floatval(count($a)+1)/2.0)); $tries = 0; while(!empty($a) && $tries<$maxtries) { echo "Try number: ".($tries+1)."\n"; print_r($a); if($a[$tries]!=1 || $tries<3) { array_push($a, $a[$tries]); } unset($a[$tries]); $tries += 1; } echo "done\n"; print_r($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 11
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 47) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
Branch analysis from position: 36
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 36
filename:       /in/hZRg7
function name:  (null)
number of ops:  42
compiled vars:  !0 = $a, !1 = $maxtries, !2 = $tries
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        COUNT                                            ~4      !0
          2        COUNT                                            ~5      !0
          3        ADD                                              ~6      ~5, 1
          4        CAST                                          5  ~7      ~6
          5        DIV                                              ~8      ~7, 2
          6        MUL                                              ~9      ~4, ~8
          7        CAST                                          4  ~10     ~9
          8        ASSIGN                                                   !1, ~10
    6     9        ASSIGN                                                   !2, 0
    7    10      > JMP                                                      ->31
    8    11    >   ADD                                              ~13     !2, 1
         12        CONCAT                                           ~14     'Try+number%3A+', ~13
         13        CONCAT                                           ~15     ~14, '%0A'
         14        ECHO                                                     ~15
    9    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                                 
   10    18        FETCH_DIM_R                                      ~17     !0, !2
         19        IS_NOT_EQUAL                                     ~18     ~17, 1
         20      > JMPNZ_EX                                         ~18     ~18, ->23
         21    >   IS_SMALLER                                       ~19     !2, 3
         22        BOOL                                             ~18     ~19
         23    > > JMPZ                                                     ~18, ->29
   11    24    >   INIT_FCALL                                               'array_push'
         25        SEND_REF                                                 !0
         26        FETCH_DIM_R                                      ~20     !0, !2
         27        SEND_VAL                                                 ~20
         28        DO_ICALL                                                 
   13    29    >   UNSET_DIM                                                !0, !2
   14    30        ASSIGN_OP                                     1          !2, 1
    7    31    >   ISSET_ISEMPTY_CV                                 ~23     !0
         32        BOOL_NOT                                         ~24     ~23
         33      > JMPZ_EX                                          ~24     ~24, ->36
         34    >   IS_SMALLER                                       ~25     !2, !1
         35        BOOL                                             ~24     ~25
         36    > > JMPNZ                                                    ~24, ->11
   16    37    >   ECHO                                                     'done%0A'
   17    38        INIT_FCALL                                               'print_r'
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.6 ms | 1400 KiB | 17 Q