Created
April 19, 2023 13:40
-
-
Save Shizumi/5c1d90b2685e162e12c05033d17a1299 to your computer and use it in GitHub Desktop.
抽選するやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$member = [ | |
'names', | |
'names', | |
'names', | |
'names', | |
'names', | |
'names', | |
'names', | |
'names', | |
'names', | |
'names', | |
]; | |
$presents = [ | |
[ | |
'name' => 'タオル', | |
'quantity' => 1, | |
'unit' => '個', | |
'offer' => 'じゅんこさん', | |
], | |
[ | |
'name' => 'タオル+ピンバッジ+シール セット', | |
'quantity' => 1, | |
'unit' => 'セット', | |
'offer' => 'shusei さん', | |
], | |
[ | |
'name' => 'スカーフ+ピンバッジ+シール セット', | |
'quantity' => 1, | |
'unit' => 'セット', | |
'offer' => 'shusei さん', | |
], | |
[ | |
'name' => 'ミステリー セットA', | |
'quantity' => 3, | |
'unit' => 'セット', | |
'offer' => 'nao さん', | |
], | |
[ | |
'name' => 'ミステリー セットB', | |
'quantity' => 3, | |
'unit' => 'セット', | |
'offer' => 'nao さん', | |
], | |
[ | |
'name' => 'Tokyo2019 Tシャツ Mサイズ', | |
'quantity' => 1, | |
'unit' => '枚', | |
'offer' => 'しずみ さん', | |
], | |
]; | |
$winners = []; | |
foreach ( $presents as $key => $item ) | |
{ | |
$winners[ $key ] = [ | |
'name' => $item['name'], | |
'unit' => sprintf( '%d%s', $item['quantity'], $item['unit'] ), | |
'offer' => $item['offer'], | |
]; | |
for ( $i = 0; $i < $item['quantity']; $i ++ ) | |
{ | |
$winner_k = array_rand( $member ); | |
$winners[ $key ]['winners'][] = $member[ $winner_k ]; | |
unset( $member[ $winner_k ] ); | |
$member = array_values( $member ); | |
} | |
} | |
?> | |
<!doctype html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" | |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>ドキドキ抽選会</title> | |
<style> | |
main { | |
width: 1200px; | |
margin: 0 auto; | |
} | |
</style> | |
</head> | |
<body> | |
<main> | |
<h1>WPZoomUP#86 WordCampAsia Swag 当選者の皆様</h1> | |
<?php foreach ( $winners as $winner ) : ?> | |
<h2><?php echo $winner['name']; ?>(提供 : <?php echo $winner['offer']; ?>)</h2> | |
<h3><?php echo $winner['unit']; ?></h3> | |
<ul> | |
<?php foreach ( $winner['winners'] as $name ) : ?> | |
<li><?php printf( '%sさん', htmlspecialchars( $name ) ); ?></li> | |
<?php endforeach; ?> | |
</ul> | |
<?php endforeach; ?> | |
</main> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment