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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.03 ms | 1412 KiB | 21 Q