3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = range(1, 2,3,4,5); // numbers to pick from $length = 4; // amount of items in the set $sets_amount = 100; // amount of sets you want to generate $existing = array(); // where we store existing sets $shuffle_period = count($numbers) - $length - 1; // how often we re-randomize the elements $j = 0; for ($i = 0; $i < $sets_amount; $i++, $j++) { if (!($i % $shuffle_period)) { shuffle($numbers); // randomize at first go and on $shuffle_period $j = 0; } do { $arr = array_slice($numbers, $j, $length); } while (in_array($arr, $existing)); $existing[] = $arr; } print_r($existing); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 18
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 25
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 18
Branch analysis from position: 42
Branch analysis from position: 18
Branch analysis from position: 25
Branch analysis from position: 25
filename:       /in/IRrIo
function name:  (null)
number of ops:  46
compiled vars:  !0 = $numbers, !1 = $length, !2 = $sets_amount, !3 = $existing, !4 = $shuffle_period, !5 = $j, !6 = $i, !7 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 2
          3        SEND_VAL                                                 3
          4        SEND_VAL                                                 4
          5        SEND_VAL                                                 5
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !0, $8
    3     8        ASSIGN                                                   !1, 4
    4     9        ASSIGN                                                   !2, 100
    5    10        ASSIGN                                                   !3, <array>
    6    11        COUNT                                            ~13     !0
         12        SUB                                              ~14     ~13, !1
         13        SUB                                              ~15     ~14, 1
         14        ASSIGN                                                   !4, ~15
    7    15        ASSIGN                                                   !5, 0
    9    16        ASSIGN                                                   !6, 0
         17      > JMP                                                      ->40
   10    18    >   MOD                                              ~19     !6, !4
         19        BOOL_NOT                                         ~20     ~19
         20      > JMPZ                                                     ~20, ->25
   11    21    >   INIT_FCALL                                               'shuffle'
         22        SEND_REF                                                 !0
         23        DO_ICALL                                                 
   12    24        ASSIGN                                                   !5, 0
   15    25    >   INIT_FCALL                                               'array_slice'
         26        SEND_VAR                                                 !0
         27        SEND_VAR                                                 !5
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $23     
         30        ASSIGN                                                   !7, $23
   16    31        INIT_FCALL                                               'in_array'
         32        SEND_VAR                                                 !7
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                         $25     
         35      > JMPNZ                                                    $25, ->25
   17    36    >   ASSIGN_DIM                                               !3
         37        OP_DATA                                                  !7
    9    38        PRE_INC                                                  !6
         39        PRE_INC                                                  !5
         40    >   IS_SMALLER                                               !6, !2
         41      > JMPNZ                                                    ~29, ->18
   20    42    >   INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !3
         44        DO_ICALL                                                 
   21    45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.28 ms | 1400 KiB | 23 Q