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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.47 ms | 1416 KiB | 21 Q