PHP code example of gift-factory / secret-santa-picker
1. Go to this page and download the library: Download gift-factory/secret-santa-picker 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/ */
gift-factory / secret-santa-picker example snippets
$players = new PlayerList([
new Player('Anna'),
new Player('Bob'),
// Bob and Dane won't be picked to send a gift to Chuck
new Player('Chuck', exclusions: ['Bob', 'Dane']),
new Player('Dane'),
// Edith and Fiona will be mutually excluded
[new Player('Edith'), new Player('Fiona')],
]);
$picker = new Picker();
$draw = $picker->pick($players);
foreach ($draw as $donor => $receiver) {
mail(
$donor->email,
'Secret Santa',
"
Hello $donor->userName,
This year, you'll be the santa of $receiver->userName,
Here is the address where to send your gift:
$receiver->realName
$receiver->address
",
);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.