boris: Tennis

Beitrag lesen

hier noch ein Schritt, kann man das optimieren?

<?php

echo "<h2>Tennis</h2>";

$points_player1a = array("0","15","30","40","DEUCE","ADV");
$points_player2a = array("0","15","30","40","DEUCE","ADV");
$points_player1 = array();
$points_player2 = array();

echo "0:0<br>";

$points_player1[] = $points_player1a[0];
$points_player2[] = $points_player2a[0];

$max_games = 6;
for ($i = 1; $i <= $max_games; $i++) {

$zufall = rand(1,2);
if ($zufall == "1") { $points_player1[] = next($points_player1a); } else { $points_player2[] = next($points_player2a); }

echo end($points_player1).":".end($points_player2)."<br>";
}

Gruss,
der Boris