| Spieler 2 |
| 6 |
| 11 |
| 12 |
| 17 |
| 19 |
| 23 |
Spieler 1 hat gewonnen
/* Initialisierung */
srand((double)microtime()*1000000);
$summea = 0;
$summeb = 0;
$a ="Spieler 1";
$b ="Spieler 2";
echo "<div style=\"float:left;background-color:#666;\">";
echo "<table border>";
echo "<tr><td algin='right'>$a</td></tr>";
while ($summea < 30 && $countera < 6)
{
$zufallszahla = rand(1,6); // würfeln
$summea = $summea + $zufallszahla;
$countera++;
echo "<tr><td align='right'>$summea </td></tr>";
}
echo "</table></div>";
###### table 2
echo "<div style='float:left;background-color:#666;'><table border>";
echo "<tr><td algin='right'>$b</td></tr>";
while ($summeb < 30 && $counterb < 6)
{
$zufallszahlb = rand(1,6); // würfeln
$summeb = $summeb + $zufallszahlb;
$counterb++;
echo "<tr><td align='right'>$summeb </td></tr>";
}
echo "</table></div>";
#### table 2 ende
### ende spiel#### anfang gewinn ermittlung ###
if ($summea > $summeb)
{
for ($i=0; $i <= 9; $i++ )
{
echo "<br />";
}
echo "<div style='background-color:#ccc;'>$a hat gewonnen</div>";
}
else if ($summeb > $summea)
{
for ($i=0; $i <= 9; $i++ )
{
echo "<br />";
}
echo "<div style='background-color:#ccc;'>$b hat gewonnen</div>";
}
else
{
for ($i=0; $i <= 9; $i++ )
{
echo "<br />";
}
echo "<div>Unentschieden, keiner Gewinnt!</div>";
}