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]); $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 = 155
Branch analysis from position: 155
2 jumps found. (Code = 44) Position 1 = 158, Position 2 = 54
Branch analysis from position: 158
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 = 154
Branch analysis from position: 81
2 jumps found. (Code = 78) Position 1 = 82, Position 2 = 154
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 100
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 153
Branch analysis from position: 153
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 100
2 jumps found. (Code = 43) Position 1 = 102, Position 2 = 118
Branch analysis from position: 102
1 jumps found. (Code = 42) Position 1 = 153
Branch analysis from position: 153
Branch analysis from position: 118
2 jumps found. (Code = 43) Position 1 = 120, Position 2 = 136
Branch analysis from position: 120
1 jumps found. (Code = 42) Position 1 = 153
Branch analysis from position: 153
Branch analysis from position: 136
2 jumps found. (Code = 43) Position 1 = 138, Position 2 = 153
Branch analysis from position: 138
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 153
Branch analysis from position: 154
2 jumps found. (Code = 44) Position 1 = 158, Position 2 = 54
Branch analysis from position: 158
Branch analysis from position: 54
Branch analysis from position: 154
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/dNIm8
function name:  (null)
number of ops:  162
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                                                      ->155
   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, ->154
         81    > > FE_FETCH_R                                               $48, !10, ->154
   36    82    >   IS_EQUAL                                                 !10, 1
         83      > JMPZ                                                     ~49, ->100
   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                                               'array_values'
         96        SEND_VAR                                                 !3
         97        DO_ICALL                                         $56     
         98        ASSIGN                                                   !3, $56
         99      > JMP                                                      ->153
   41   100    >   IS_EQUAL                                                 !10, 2
        101      > JMPZ                                                     ~58, ->118
   42   102    >   INIT_FCALL                                               'mt_rand'
        103        SEND_VAL                                                 0
        104        COUNT                                            ~59     !4
        105        SUB                                              ~60     ~59, 1
        106        SEND_VAL                                                 ~60
        107        DO_ICALL                                         $61     
        108        ASSIGN                                                   !11, $61
   43   109        FETCH_DIM_R                                      ~64     !4, !11
        110        ASSIGN_DIM                                               !7
        111        OP_DATA                                                  ~64
   44   112        UNSET_DIM                                                !4, !11
   45   113        INIT_FCALL                                               'array_values'
        114        SEND_VAR                                                 !4
        115        DO_ICALL                                         $65     
        116        ASSIGN                                                   !4, $65
        117      > JMP                                                      ->153
   46   118    >   IS_EQUAL                                                 !10, 3
        119      > JMPZ                                                     ~67, ->136
   47   120    >   INIT_FCALL                                               'mt_rand'
        121        SEND_VAL                                                 0
        122        COUNT                                            ~68     !5
        123        SUB                                              ~69     ~68, 1
        124        SEND_VAL                                                 ~69
        125        DO_ICALL                                         $70     
        126        ASSIGN                                                   !11, $70
   48   127        FETCH_DIM_R                                      ~73     !5, !11
        128        ASSIGN_DIM                                               !7
        129        OP_DATA                                                  ~73
   49   130        UNSET_DIM                                                !5, !11
   50   131        INIT_FCALL                                               'array_values'
        132        SEND_VAR                                                 !5
        133        DO_ICALL                                         $74     
        134        ASSIGN                                                   !5, $74
        135      > JMP                                                      ->153
   51   136    >   IS_EQUAL                                                 !10, 4
        137      > JMPZ                                                     ~76, ->153
   52   138    >   INIT_FCALL                                               'mt_rand'
        139        SEND_VAL                                                 0
        140        COUNT                                            ~77     !6
        141        SUB                                              ~78     ~77, 1
        142        SEND_VAL                                                 ~78
        143        DO_ICALL                                         $79     
        144        ASSIGN                                                   !11, $79
   53   145        FETCH_DIM_R                                      ~82     !6, !11
        146        ASSIGN_DIM                                               !7
        147        OP_DATA                                                  ~82
   54   148        UNSET_DIM                                                !6, !11
   55   149        INIT_FCALL                                               'array_values'
        150        SEND_VAR                                                 !6
        151        DO_ICALL                                         $83     
        152        ASSIGN                                                   !6, $83
   35   153    > > JMP                                                      ->81
        154    >   FE_FREE                                                  $48
   24   155    >   COUNT                                            ~85     !7
        156        IS_SMALLER                                               ~85, !1
        157      > JMPNZ                                                    ~86, ->54
   61   158    >   INIT_FCALL                                               'print_r'
        159        SEND_VAR                                                 !7
        160        DO_ICALL                                                 
   63   161      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.21 ms | 1412 KiB | 21 Q