3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbers = range(1, 2,3); // numbers to pick from $length = 2; // 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 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 16
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 23
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 16
Branch analysis from position: 40
Branch analysis from position: 16
Branch analysis from position: 23
Branch analysis from position: 23
filename:       /in/KCs28
function name:  (null)
number of ops:  44
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        DO_ICALL                                         $8      
          5        ASSIGN                                                   !0, $8
    3     6        ASSIGN                                                   !1, 2
    4     7        ASSIGN                                                   !2, 100
    5     8        ASSIGN                                                   !3, <array>
    6     9        COUNT                                            ~13     !0
         10        SUB                                              ~14     ~13, !1
         11        SUB                                              ~15     ~14, 1
         12        ASSIGN                                                   !4, ~15
    7    13        ASSIGN                                                   !5, 0
    9    14        ASSIGN                                                   !6, 0
         15      > JMP                                                      ->38
   10    16    >   MOD                                              ~19     !6, !4
         17        BOOL_NOT                                         ~20     ~19
         18      > JMPZ                                                     ~20, ->23
   11    19    >   INIT_FCALL                                               'shuffle'
         20        SEND_REF                                                 !0
         21        DO_ICALL                                                 
   12    22        ASSIGN                                                   !5, 0
   15    23    >   INIT_FCALL                                               'array_slice'
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !5
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $23     
         28        ASSIGN                                                   !7, $23
   16    29        INIT_FCALL                                               'in_array'
         30        SEND_VAR                                                 !7
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                         $25     
         33      > JMPNZ                                                    $25, ->23
   17    34    >   ASSIGN_DIM                                               !3
         35        OP_DATA                                                  !7
    9    36        PRE_INC                                                  !6
         37        PRE_INC                                                  !5
         38    >   IS_SMALLER                                               !6, !2
         39      > JMPNZ                                                    ~29, ->16
   20    40    >   INIT_FCALL                                               'print_r'
         41        SEND_VAR                                                 !3
         42        DO_ICALL                                                 
   21    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.09 ms | 1400 KiB | 23 Q