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]==0 || $a[$tries]<$a[$tries+1]) { 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 = 34
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 11
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 47) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 32
Branch analysis from position: 27
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
Branch analysis from position: 39
Branch analysis from position: 32
Branch analysis from position: 26
Branch analysis from position: 39
filename:       /in/9kPhL
function name:  (null)
number of ops:  45
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                                                      ->34
    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_EQUAL                                         ~18     ~17, 0
         20      > JMPNZ_EX                                         ~18     ~18, ->26
         21    >   FETCH_DIM_R                                      ~19     !0, !2
         22        ADD                                              ~20     !2, 1
         23        FETCH_DIM_R                                      ~21     !0, ~20
         24        IS_SMALLER                                       ~22     ~19, ~21
         25        BOOL                                             ~18     ~22
         26    > > JMPZ                                                     ~18, ->32
   11    27    >   INIT_FCALL                                               'array_push'
         28        SEND_REF                                                 !0
         29        FETCH_DIM_R                                      ~23     !0, !2
         30        SEND_VAL                                                 ~23
         31        DO_ICALL                                                 
   13    32    >   UNSET_DIM                                                !0, !2
   14    33        ASSIGN_OP                                     1          !2, 1
    7    34    >   ISSET_ISEMPTY_CV                                 ~26     !0
         35        BOOL_NOT                                         ~27     ~26
         36      > JMPZ_EX                                          ~27     ~27, ->39
         37    >   IS_SMALLER                                       ~28     !2, !1
         38        BOOL                                             ~27     ~28
         39    > > JMPNZ                                                    ~27, ->11
   16    40    >   ECHO                                                     'done%0A'
   17    41        INIT_FCALL                                               'print_r'
         42        SEND_VAR                                                 !0
         43        DO_ICALL                                                 
         44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.54 ms | 1400 KiB | 17 Q