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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.13 ms | 1408 KiB | 19 Q