PHP Classes

Generate a list of unique numbersPHP Unique Number Generator: generateUniquesNumbers

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 110 All time: 9,646 This week: 560Up
Version License PHP version Categories
generateuniquesnumbe 1.0.0GNU General Publi...5PHP 5, Statistics, Math
Description 

Author

This class can generate a list of unique numbers.

It can generate an array of random integer numbers that are unique between themselves.

The class may exclude a given list of numbers from those that are generated.

Picture of Elminson De Oleo
  Performance   Level  
Name: Elminson De Oleo <contact>
Classes: 5 packages by
Country: United States United States
Age: 44
All time rank: 2412329 in United States United States
Week rank: 214 Up28 in United States United States Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php

require_once __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload

use Elminson\GenerateUniquesNumbers;

$array = [1, 2, 3, 4];

$gen = new generateUniqueNumbers();

$gen->setMax(10);

$gen->setExclude($array);

$gen->setTopRandomNumber(5);

$gen->generate();

print_r($gen->getCurrentNumbers());

//Output
Array
(
    [
0] => 0
   
[1] => 9
   
[2] => 6
   
[3] => 10
   
[4] => 5
)


Details

generateUniquesNumbers

<?php 

require_once __DIR__ . '/vendor/autoload.php'; // Autoload files using Composer autoload

use Elminson\GenerateUniquesNumbers;

$array = [1, 2, 3, 4];

$gen = new generateUniqueNumbers();

$gen->setMax(10);

$gen->setExclude($array);

$gen->setTopRandomNumber(5);

$gen->generate();

print_r($gen->getCurrentNumbers());

//Output
Array
(
    [0] => 0
    [1] => 9
    [2] => 6
    [3] => 10
    [4] => 5
)


  Files folder image Files (7)  
File Role Description
Files folder imagesrc (1 directory)
Files folder imagetests (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file test.php Example Test file

  Files folder image Files (7)  /  src  
File Role Description
Files folder imageElminson (1 file)

  Files folder image Files (7)  /  src  /  Elminson  
File Role Description
  Plain text file GenerateUniquesNumbers.php Class Class source

  Files folder image Files (7)  /  tests  
File Role Description
  Accessible without login Plain text file test.php Example Example script
  Plain text file testGenerateUniquesNumbers.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 85%
Total:110
This week:0
All time:9,646
This week:560Up