PHP Classes

Generate a list of unique numbersPHP Unique Number Generator: generateUniquesNumbers

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 110 All time: 9,624 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: 43
All time rank: 2415330 in United States United States
Week rank: 416 Up46 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  
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  /  src  
File Role Description
Files folder imageElminson (1 file)

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

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

 Version Control Unique User Downloads Download Rankings  
 85%
Total:110
This week:0
All time:9,624
This week:560Up