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(); $group_order[] = array(); while(count($new_arr)<$size){ foreach ($group_order as $i => $value) { unset($group_order[$i]); } $group_order = array_values($group_order); $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]); $a = array_values($a); }elseif ($value == 2){ $idx = mt_rand(0,(count($b)-1)); $new_arr[] = $b[$idx]; unset($b[$idx]); $b = array_values($b); }elseif ($value == 3){ $idx = mt_rand(0,(count($c)-1)); $new_arr[] = $c[$idx]; unset($c[$idx]); $c = array_values($c); }elseif ($value == 4){ $idx = mt_rand(0,(count($d)-1)); $new_arr[] = $d[$idx]; unset($d[$idx]); $d = array_values($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 = 167
Branch analysis from position: 167
2 jumps found. (Code = 44) Position 1 = 170, Position 2 = 56
Branch analysis from position: 170
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
2 jumps found. (Code = 77) Position 1 = 57, Position 2 = 61
Branch analysis from position: 57
2 jumps found. (Code = 78) Position 1 = 58, Position 2 = 61
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 86
Branch analysis from position: 86
2 jumps found. (Code = 44) Position 1 = 89, Position 2 = 73
Branch analysis from position: 89
2 jumps found. (Code = 77) Position 1 = 93, Position 2 = 166
Branch analysis from position: 93
2 jumps found. (Code = 78) Position 1 = 94, Position 2 = 166
Branch analysis from position: 94
2 jumps found. (Code = 43) Position 1 = 96, Position 2 = 112
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 165
Branch analysis from position: 165
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
Branch analysis from position: 112
2 jumps found. (Code = 43) Position 1 = 114, Position 2 = 130
Branch analysis from position: 114
1 jumps found. (Code = 42) Position 1 = 165
Branch analysis from position: 165
Branch analysis from position: 130
2 jumps found. (Code = 43) Position 1 = 132, Position 2 = 148
Branch analysis from position: 132
1 jumps found. (Code = 42) Position 1 = 165
Branch analysis from position: 165
Branch analysis from position: 148
2 jumps found. (Code = 43) Position 1 = 150, Position 2 = 165
Branch analysis from position: 150
1 jumps found. (Code = 42) Position 1 = 93
Branch analysis from position: 93
Branch analysis from position: 165
Branch analysis from position: 166
2 jumps found. (Code = 44) Position 1 = 170, Position 2 = 56
Branch analysis from position: 170
Branch analysis from position: 56
Branch analysis from position: 166
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 86
Branch analysis from position: 84
2 jumps found. (Code = 44) Position 1 = 89, Position 2 = 73
Branch analysis from position: 89
Branch analysis from position: 73
Branch analysis from position: 86
Branch analysis from position: 61
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/TlRI5
function name:  (null)
number of ops:  174
compiled vars:  !0 = $old_arr, !1 = $size, !2 = $i, !3 = $a, !4 = $b, !5 = $c, !6 = $d, !7 = $new_arr, !8 = $group_order, !9 = $value, !10 = $x, !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        ASSIGN_DIM                                               !8
         54        OP_DATA                                                  <array>
   25    55      > JMP                                                      ->167
   26    56    > > FE_RESET_R                                       $39     !8, ->61
         57    > > FE_FETCH_R                                       ~40     $39, !9, ->61
         58    >   ASSIGN                                                   !2, ~40
   27    59        UNSET_DIM                                                !8, !2
   26    60      > JMP                                                      ->57
         61    >   FE_FREE                                                  $39
   29    62        INIT_FCALL                                               'array_values'
         63        SEND_VAR                                                 !8
         64        DO_ICALL                                         $42     
         65        ASSIGN                                                   !8, $42
   30    66        INIT_FCALL                                               'mt_rand'
         67        SEND_VAL                                                 1
         68        SEND_VAL                                                 4
         69        DO_ICALL                                         $45     
         70        ASSIGN_DIM                                               !8
         71        OP_DATA                                                  $45
   31    72      > JMP                                                      ->86
   32    73    >   INIT_FCALL                                               'mt_rand'
         74        SEND_VAL                                                 1
         75        SEND_VAL                                                 4
         76        DO_ICALL                                         $46     
         77        ASSIGN                                                   !10, $46
   33    78        INIT_FCALL                                               'in_array'
         79        SEND_VAR                                                 !10
         80        SEND_VAR                                                 !8
         81        DO_ICALL                                         $48     
         82        BOOL_NOT                                         ~49     $48
         83      > JMPZ                                                     ~49, ->86
   34    84    >   ASSIGN_DIM                                               !8
         85        OP_DATA                                                  !10
   31    86    >   COUNT                                            ~51     !8
         87        IS_SMALLER                                               ~51, 4
         88      > JMPNZ                                                    ~52, ->73
   37    89    >   INIT_FCALL                                               'print_r'
         90        SEND_VAR                                                 !8
         91        DO_ICALL                                                 
   39    92      > FE_RESET_R                                       $54     !8, ->166
         93    > > FE_FETCH_R                                               $54, !9, ->166
   40    94    >   IS_EQUAL                                                 !9, 1
         95      > JMPZ                                                     ~55, ->112
   41    96    >   INIT_FCALL                                               'mt_rand'
         97        SEND_VAL                                                 0
         98        COUNT                                            ~56     !3
         99        SUB                                              ~57     ~56, 1
        100        SEND_VAL                                                 ~57
        101        DO_ICALL                                         $58     
        102        ASSIGN                                                   !11, $58
   42   103        FETCH_DIM_R                                      ~61     !3, !11
        104        ASSIGN_DIM                                               !7
        105        OP_DATA                                                  ~61
   43   106        UNSET_DIM                                                !3, !11
   44   107        INIT_FCALL                                               'array_values'
        108        SEND_VAR                                                 !3
        109        DO_ICALL                                         $62     
        110        ASSIGN                                                   !3, $62
        111      > JMP                                                      ->165
   45   112    >   IS_EQUAL                                                 !9, 2
        113      > JMPZ                                                     ~64, ->130
   46   114    >   INIT_FCALL                                               'mt_rand'
        115        SEND_VAL                                                 0
        116        COUNT                                            ~65     !4
        117        SUB                                              ~66     ~65, 1
        118        SEND_VAL                                                 ~66
        119        DO_ICALL                                         $67     
        120        ASSIGN                                                   !11, $67
   47   121        FETCH_DIM_R                                      ~70     !4, !11
        122        ASSIGN_DIM                                               !7
        123        OP_DATA                                                  ~70
   48   124        UNSET_DIM                                                !4, !11
   49   125        INIT_FCALL                                               'array_values'
        126        SEND_VAR                                                 !4
        127        DO_ICALL                                         $71     
        128        ASSIGN                                                   !4, $71
        129      > JMP                                                      ->165
   50   130    >   IS_EQUAL                                                 !9, 3
        131      > JMPZ                                                     ~73, ->148
   51   132    >   INIT_FCALL                                               'mt_rand'
        133        SEND_VAL                                                 0
        134        COUNT                                            ~74     !5
        135        SUB                                              ~75     ~74, 1
        136        SEND_VAL                                                 ~75
        137        DO_ICALL                                         $76     
        138        ASSIGN                                                   !11, $76
   52   139        FETCH_DIM_R                                      ~79     !5, !11
        140        ASSIGN_DIM                                               !7
        141        OP_DATA                                                  ~79
   53   142        UNSET_DIM                                                !5, !11
   54   143        INIT_FCALL                                               'array_values'
        144        SEND_VAR                                                 !5
        145        DO_ICALL                                         $80     
        146        ASSIGN                                                   !5, $80
        147      > JMP                                                      ->165
   55   148    >   IS_EQUAL                                                 !9, 4
        149      > JMPZ                                                     ~82, ->165
   56   150    >   INIT_FCALL                                               'mt_rand'
        151        SEND_VAL                                                 0
        152        COUNT                                            ~83     !6
        153        SUB                                              ~84     ~83, 1
        154        SEND_VAL                                                 ~84
        155        DO_ICALL                                         $85     
        156        ASSIGN                                                   !11, $85
   57   157        FETCH_DIM_R                                      ~88     !6, !11
        158        ASSIGN_DIM                                               !7
        159        OP_DATA                                                  ~88
   58   160        UNSET_DIM                                                !6, !11
   59   161        INIT_FCALL                                               'array_values'
        162        SEND_VAR                                                 !6
        163        DO_ICALL                                         $89     
        164        ASSIGN                                                   !6, $89
   39   165    > > JMP                                                      ->93
        166    >   FE_FREE                                                  $54
   25   167    >   COUNT                                            ~91     !7
        168        IS_SMALLER                                               ~91, !1
        169      > JMPNZ                                                    ~92, ->56
   65   170    >   INIT_FCALL                                               'print_r'
        171        SEND_VAR                                                 !7
        172        DO_ICALL                                                 
   67   173      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.96 ms | 1412 KiB | 21 Q