Code: Select all
<?php
$Bells="<img src='bells.png'>";
$Cherry="<img src='cherry.png'>";
$Watermellon="<img src='watermellon.png'>";
$Diamond="<img src='diamond1.png'>";
$Seven="<img src='seven.png'>";
$Orange="<img src='orange.png'>";
$faces = array ('<img src = "cherry.png" name = "Cherry">', '<img src = "bells.png" name = "Bells">', '<img src = "orange.png">', '<img src = "watermellon.png">', '<img src = "diamond1.png" name = "Diamond">', '<img src = "seven.png" name = "Seven">');
$payouts = array (
'$Bells|$Bells|$Bells' => '5',
'$Watermellon|$Watermellon|$Watermellon' => '10',
'$Orange|$Orange|$Orange' => '15',
'$Cherry|$Cherry|$Cherry' => '20',
'$Seven|$Seven|$Seven' => '70',
'$Diamond|$Diamond|$Diamond' => '100',
);
$wheel1 = array();
foreach ($faces as $face) {
$wheel1[] = $face;
}
$wheel2 = array_reverse($wheel1);
$wheel3 = $wheel1;
if (isset($_POST['payline'])) {
list($start1, $start2, $start3) = unserialize($_POST['payline']);
} else {
list($start1, $start2, $start3) = array(0,0,0);
}
$stop1 = rand(count($wheel1)+$start1, 10*count($wheel1)) % count($wheel1);
$stop2 = rand(count($wheel1)+$start2, 10*count($wheel1)) % count($wheel1);
$stop3 = rand(count($wheel1)+$start3, 10*count($wheel1)) % count($wheel1);
$result1 = $wheel1[$stop1];
$result2 = $wheel2[$stop2];
$result3 = $wheel3[$stop3];
echo "Result: " . $result1 . ' ' . $result2 . ' ' . $result3 . "<br />";
if (isset($payouts[$result1.'|'.$result2.'|'.$result3])) {
// give the payout
echo "You won : " . $payouts[$result1.'|'.$result2.'|'.$result3];
}
?>
<br />
<form method='post'>
<input type='hidden' name='payline' value='<?php echo serialize(array($stop1, $stop2, $stop3)) ?>' />
<input type='submit' value='spin the wheel' />
</form>