PHP code example of luffy / randomizer

1. Go to this page and download the library: Download luffy/randomizer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luffy / randomizer example snippets


use  luffy\random\Randomizer;
$generator=new Randomizer('449c131f-0171-401e-80c9-xxxxxxxxx'); //参数是你在random.org申请的API key

$generator->integers($quantity,$min,$max,$base=10,$replacement=true)

array(3) {
  ["errno"]=>
  int(0)
  ["error"]=>
  string(7) "success"
  ["data"]=>
  array(10) {
    [0]=>
    int(22)
    [1]=>
    int(9)
    [2]=>
    int(89)
    [3]=>
    int(98)
    [4]=>
    int(79)
    [5]=>
    int(1)
    [6]=>
    int(3)
    [7]=>
    int(83)
    [8]=>
    int(67)
    [9]=>
    int(29)
  }
}


array(3) {
  ["errno"]=>
  int(201)
  ["error"]=>
  string(34) "Parameter 'base' has illegal value"
  ["data"]=>
  NULL
}

$generator->decimalFractions($quantity,$decimalPlaces,$replacement=true)

$generator->gaussians($quantity,$mean,$standardDeviation,$significantDigits)

$generator->strings($quantity,$length,$characters,$replacement=true)

$generator->uuids($quantity)

$generator->blobs($quantity,$size,$format='base64')

$generator->usage();

array(3) {
  ["errno"]=>
  int(0)
  ["error"]=>
  string(7) "success"
  ["data"]=>
  array(6) {
    ["status"]=>
    string(7) "running"
    ["creationTime"]=>
    string(20) "2018-09-30 08:17:55Z"
    ["bitsLeft"]=>
    int(249604)
    ["requestsLeft"]=>
    int(994)
    ["totalBits"]=>
    int(21471)
    ["totalRequests"]=>
    int(99)
  }
}