<?php


$faces = array ('4', '1', '2', '3', '6', '5');

$payouts = array (
    '1|1|1' => '0,01',
    '2|2|2' => '0,02',
    '3|3|3' => '0,03',
    '4|4|4' => '0,05',
    '5|5|5' => '0,07',
    '6|6|6' => '0,10',
);


$wheel1 = array();
foreach ($faces as $face) {
    $wheel1[] = $face;
}
$wheel2 = array_reverse($wheel1);
$wheel3 = $wheel1;
?>
<center>
<?php
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>
<center>

who can help me ? :)

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

What is it supposed to do?

$faces = array ('4', '1', '2', '3', '6', '5');
$wheel1 = array();
foreach ($faces as $face) {
    $wheel1[] = $face;
}

Wouldn't be simplier:$wheel1 = $faces;?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.