3v4l.org

run code in 300+ PHP versions simultaneously
<?php $old_arr=array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20); $size = count($old_arr); print_r($size); for($i=0;$i<=19;$i++){ if ($i<=4){ $a[] = $old_arr[$i]; }elseif ($i>4 && $i<=9){ $b[] = $old_arr[$i]; }elseif ($i>9 && $i<=14){ $c[] = $old_arr[$i]; }elseif ($i>14){ $d[] = $old_arr[$i]; } } print_r($a); print_r($b); print_r($c); print_r($d); $new_arr = array(); while(count($new_arr)<$size){ $group_order[] = mt_rand(1,4); while(count($group_order)<4){ $x=mt_rand(1,4); if(in_array($x,$group_order) == false){ $group_order[] = $x; } } print_r($group_order); foreach ($group_order as $value){ if ($value == 1){ $idx = mt_rand(0,(count($a)-1)); $new_arr[] = $a[$idx]; unset($a[$idx]); print_r($a); }elseif ($value == 2){ $idx = mt_rand(0,(count($b)-1)); $new_arr[] = $b[$idx]; unset($b[$idx]); print_r($b); }elseif ($value == 3){ $idx = mt_rand(0,(count($c)-1)); $new_arr[] = $c[$idx]; unset($c[$idx]); print_r($c); }elseif ($value == 4){ $idx = mt_rand(0,(count($d)-1)); $new_arr[] = $d[$idx]; unset($d[$idx]); print_r($d); } } } print_r($new_arr); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 8
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 151
Branch analysis from position: 151
2 jumps found. (Code = 44) Position 1 = 154, Position 2 = 54
Branch analysis from position: 154
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 61
Branch analysis from position: 77
2 jumps found. (Code = 77) Position 1 = 81, Position 2 = 150
Branch analysis from position: 81
2 jumps found. (Code = 78) Position 1 = 82, Position 2 = 150
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 99
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 149
Branch analysis from position: 149
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 99
2 jumps found. (Code = 43) Position 1 = 101, Position 2 = 116
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 149
Branch analysis from position: 149
Branch analysis from position: 116
2 jumps found. (Code = 43) Position 1 = 118, Position 2 = 133
Branch analysis from position: 118
1 jumps found. (Code = 42) Position 1 = 149
Branch analysis from position: 149
Branch analysis from position: 133
2 jumps found. (Code = 43) Position 1 = 135, Position 2 = 149
Branch analysis from position: 135
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 149
Branch analysis from position: 150
2 jumps found. (Code = 44) Position 1 = 154, Position 2 = 54
Branch analysis from position: 154
Branch analysis from position: 54
Branch analysis from position: 150
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 74
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 61
Branch analysis from position: 77
Branch analysis from position: 61
Branch analysis from position: 74
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 8
Branch analysis from position: 40
Branch analysis from position: 8
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 23
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 37
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 8
Branch analysis from position: 40
Branch analysis from position: 8
Branch analysis from position: 37
Branch analysis from position: 27
Branch analysis from position: 18
filename:       /in/s5k3N
function name:  (null)
number of ops:  158
compiled vars:  !0 = $old_arr, !1 = $size, !2 = $i, !3 = $a, !4 = $b, !5 = $c, !6 = $d, !7 = $new_arr, !8 = $group_order, !9 = $x, !10 = $value, !11 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        COUNT                                            ~13     !0
          2        ASSIGN                                                   !1, ~13
    5     3        INIT_FCALL                                               'print_r'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
    7     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->38
    8     8    >   IS_SMALLER_OR_EQUAL                                      !2, 4
          9      > JMPZ                                                     ~17, ->14
    9    10    >   FETCH_DIM_R                                      ~19     !0, !2
         11        ASSIGN_DIM                                               !3
         12        OP_DATA                                                  ~19
         13      > JMP                                                      ->37
   10    14    >   IS_SMALLER                                       ~20     4, !2
         15      > JMPZ_EX                                          ~20     ~20, ->18
         16    >   IS_SMALLER_OR_EQUAL                              ~21     !2, 9
         17        BOOL                                             ~20     ~21
         18    > > JMPZ                                                     ~20, ->23
   11    19    >   FETCH_DIM_R                                      ~23     !0, !2
         20        ASSIGN_DIM                                               !4
         21        OP_DATA                                                  ~23
         22      > JMP                                                      ->37
   12    23    >   IS_SMALLER                                       ~24     9, !2
         24      > JMPZ_EX                                          ~24     ~24, ->27
         25    >   IS_SMALLER_OR_EQUAL                              ~25     !2, 14
         26        BOOL                                             ~24     ~25
         27    > > JMPZ                                                     ~24, ->32
   13    28    >   FETCH_DIM_R                                      ~27     !0, !2
         29        ASSIGN_DIM                                               !5
         30        OP_DATA                                                  ~27
         31      > JMP                                                      ->37
   14    32    >   IS_SMALLER                                               14, !2
         33      > JMPZ                                                     ~28, ->37
   15    34    >   FETCH_DIM_R                                      ~30     !0, !2
         35        ASSIGN_DIM                                               !6
         36        OP_DATA                                                  ~30
    7    37    >   PRE_INC                                                  !2
         38    >   IS_SMALLER_OR_EQUAL                                      !2, 19
         39      > JMPNZ                                                    ~32, ->8
   18    40    >   INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                                 
   19    43        INIT_FCALL                                               'print_r'
         44        SEND_VAR                                                 !4
         45        DO_ICALL                                                 
   20    46        INIT_FCALL                                               'print_r'
         47        SEND_VAR                                                 !5
         48        DO_ICALL                                                 
   21    49        INIT_FCALL                                               'print_r'
         50        SEND_VAR                                                 !6
         51        DO_ICALL                                                 
   23    52        ASSIGN                                                   !7, <array>
   24    53      > JMP                                                      ->151
   26    54    >   INIT_FCALL                                               'mt_rand'
         55        SEND_VAL                                                 1
         56        SEND_VAL                                                 4
         57        DO_ICALL                                         $39     
         58        ASSIGN_DIM                                               !8
         59        OP_DATA                                                  $39
   27    60      > JMP                                                      ->74
   28    61    >   INIT_FCALL                                               'mt_rand'
         62        SEND_VAL                                                 1
         63        SEND_VAL                                                 4
         64        DO_ICALL                                         $40     
         65        ASSIGN                                                   !9, $40
   29    66        INIT_FCALL                                               'in_array'
         67        SEND_VAR                                                 !9
         68        SEND_VAR                                                 !8
         69        DO_ICALL                                         $42     
         70        BOOL_NOT                                         ~43     $42
         71      > JMPZ                                                     ~43, ->74
   30    72    >   ASSIGN_DIM                                               !8
         73        OP_DATA                                                  !9
   27    74    >   COUNT                                            ~45     !8
         75        IS_SMALLER                                               ~45, 4
         76      > JMPNZ                                                    ~46, ->61
   33    77    >   INIT_FCALL                                               'print_r'
         78        SEND_VAR                                                 !8
         79        DO_ICALL                                                 
   35    80      > FE_RESET_R                                       $48     !8, ->150
         81    > > FE_FETCH_R                                               $48, !10, ->150
   36    82    >   IS_EQUAL                                                 !10, 1
         83      > JMPZ                                                     ~49, ->99
   37    84    >   INIT_FCALL                                               'mt_rand'
         85        SEND_VAL                                                 0
         86        COUNT                                            ~50     !3
         87        SUB                                              ~51     ~50, 1
         88        SEND_VAL                                                 ~51
         89        DO_ICALL                                         $52     
         90        ASSIGN                                                   !11, $52
   38    91        FETCH_DIM_R                                      ~55     !3, !11
         92        ASSIGN_DIM                                               !7
         93        OP_DATA                                                  ~55
   39    94        UNSET_DIM                                                !3, !11
   40    95        INIT_FCALL                                               'print_r'
         96        SEND_VAR                                                 !3
         97        DO_ICALL                                                 
         98      > JMP                                                      ->149
   41    99    >   IS_EQUAL                                                 !10, 2
        100      > JMPZ                                                     ~57, ->116
   42   101    >   INIT_FCALL                                               'mt_rand'
        102        SEND_VAL                                                 0
        103        COUNT                                            ~58     !4
        104        SUB                                              ~59     ~58, 1
        105        SEND_VAL                                                 ~59
        106        DO_ICALL                                         $60     
        107        ASSIGN                                                   !11, $60
   43   108        FETCH_DIM_R                                      ~63     !4, !11
        109        ASSIGN_DIM                                               !7
        110        OP_DATA                                                  ~63
   44   111        UNSET_DIM                                                !4, !11
   45   112        INIT_FCALL                                               'print_r'
        113        SEND_VAR                                                 !4
        114        DO_ICALL                                                 
        115      > JMP                                                      ->149
   46   116    >   IS_EQUAL                                                 !10, 3
        117      > JMPZ                                                     ~65, ->133
   47   118    >   INIT_FCALL                                               'mt_rand'
        119        SEND_VAL                                                 0
        120        COUNT                                            ~66     !5
        121        SUB                                              ~67     ~66, 1
        122        SEND_VAL                                                 ~67
        123        DO_ICALL                                         $68     
        124        ASSIGN                                                   !11, $68
   48   125        FETCH_DIM_R                                      ~71     !5, !11
        126        ASSIGN_DIM                                               !7
        127        OP_DATA                                                  ~71
   49   128        UNSET_DIM                                                !5, !11
   50   129        INIT_FCALL                                               'print_r'
        130        SEND_VAR                                                 !5
        131        DO_ICALL                                                 
        132      > JMP                                                      ->149
   51   133    >   IS_EQUAL                                                 !10, 4
        134      > JMPZ                                                     ~73, ->149
   52   135    >   INIT_FCALL                                               'mt_rand'
        136        SEND_VAL                                                 0
        137        COUNT                                            ~74     !6
        138        SUB                                              ~75     ~74, 1
        139        SEND_VAL                                                 ~75
        140        DO_ICALL                                         $76     
        141        ASSIGN                                                   !11, $76
   53   142        FETCH_DIM_R                                      ~79     !6, !11
        143        ASSIGN_DIM                                               !7
        144        OP_DATA                                                  ~79
   54   145        UNSET_DIM                                                !6, !11
   55   146        INIT_FCALL                                               'print_r'
        147        SEND_VAR                                                 !6
        148        DO_ICALL                                                 
   35   149    > > JMP                                                      ->81
        150    >   FE_FREE                                                  $48
   24   151    >   COUNT                                            ~81     !7
        152        IS_SMALLER                                               ~81, !1
        153      > JMPNZ                                                    ~82, ->54
   61   154    >   INIT_FCALL                                               'print_r'
        155        SEND_VAR                                                 !7
        156        DO_ICALL                                                 
   63   157      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.98 ms | 1416 KiB | 19 Q