PHP code example of wataridori / bias-random

1. Go to this page and download the library: Download wataridori/bias-random 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/ */

    

wataridori / bias-random example snippets


$biasRandom = new wataridori/BiasRandom/BiasRandom();
$data = [
    'wataridori' => 10,
];
$biasRandom->setData($data);
$biasRandom->addElement('Tran', 20);
$biasRandom->addElement('Duc', 30);
$biasRandom->addElement('Thang', 40);

// Random one element with weight.
$biasRandom->random();

// Random two elements
$biasRandom->random(2);