PHP code example of infocyph / game-draw
1. Go to this page and download the library: Download infocyph/game-draw 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/ */
infocyph / game-draw example snippets
$products = [
[
'item' => 'product_000_NoLuck', // Item code or Identifier
'chances' => '100000', // Item Chances
'amounts'=> [ 1 ] // Item Amounts
],
[
'item' => 'product_001',
'chances' => '1000',
'amounts' => '1.5,10.00001,1' // Weighted CSV formatted range (min,max,bias)
],
[
'item' => 'product_002',
'chances' => '500.001', // Fraction Allowed
'amounts' => [
1 => 100, // Amount chances
5 => 50, // Format: Amount => Chances
10 => 10.002, // Fraction allowed
]
],
[
'item' => 'product_003',
'chances' => '100',
'amounts' => [
1 => 100,
5 => 50,
10 => 10,
20 => 5,
]
],
[
'item' => 'product_004',
'chances' => '1',
'amounts' => [ 10, 15, 30, 50 ] // Amounts without probability
],
]
[
5 => 100,
15 => 50,
50 => 10,
80 => 5.001
]
$luckyDraw = new AbmmHasan\Draw\LuckyDraw($products);
$result = $luckyDraw->pick();
[
'item' => 'product_000_NoLuck',
'amount' => 1
]
$prizes =
[
'product_001'=>50, // Item Code/Identifier => Amount of the item
'product_002'=>5,
'product_003'=>3,
'product_004'=>2,
'product_005'=>1
];
$grandDraw = new AbmmHasan\Draw\GrandDraw();
$grandDraw->setItems($prizes)
->setUserListFilePath('./Sample1000.csv');
$winners = $grandDraw->getWinners();
[
'product_001' => ['usr47671', 'usr57665', 'usr92400'],
'product_002' => ['usr50344', 'usr60450', 'usr62662']
]
$items = [
['name' => 'item1', 'weight' => 10],
['name' => 'item2', 'weight' => 20],
];
$items = [
['name' => 'item1'],
['name' => 'item2'],
];
$items = [
['name' => 'item1', 'weight' => 10],
['name' => 'item2', 'weight' => 20],
];
$items = [
['name' => 'item1'],
['name' => 'item2'],
];
$items = [
['name' => 'item1'],
['name' => 'item2'],
];
$items = [
['name' => 'item1'],
['name' => 'item2'],
];
$items = [
['name' => 'item1', 'weight' => 10, 'time' => 'daily'],
['name' => 'item2', 'weight' => 20, 'time' => 'weekly'],
];
$items = [
['name' => 'item1', 'weight' => 10],
['name' => 'item2', 'weight' => 20],
];
$items = [
['name' => 'item1'],
['name' => 'item2'],
];
$items = [
['name' => 'item1', 'min' => 1, 'max' => 50, 'weight' => 10],
['name' => 'item2', 'min' => 5, 'max' => 25, 'weight' => 15],
];
$flexibleDraw = new FlexibleDraw($items);
$result = $flexibleDraw->draw('drawType'); // Replace 'drawType' with the desired draw type, e.g., 'probability'
[
'item' => 'item2',
'weight' => 20,
]