1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| <?php
function Loterie($debut,$quantite_elements,$nb_tirage)
{
$limite = $debut + $quantite_elements -1;
// création du tableau
$tab = range($debut,$limite);
// mélange du tableau
shuffle($tab);
// prend les $nb_tirage premiers
$tab_tirage = array_slice($tab, 0, $nb_tirage);
return $tab_tirage;
}
$debut = 1;
$quantite_elements = 20;
$nb_tirage = 8;
$numbers1 = Loterie($debut,$quantite_elements,$nb_tirage);
$debut = 21;
$numbers2 = Loterie($debut,$quantite_elements,$nb_tirage);
$debut = 41;
$numbers3 = Loterie($debut,$quantite_elements,$nb_tirage);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script>
var tab_php1 = <?php echo json_encode($numbers1)?>;
var tab_php2 = <?php echo json_encode($numbers2)?>;
var tab_php3 = <?php echo json_encode($numbers3)?>;
function Affiche(i,tab,id){
i++;
if (typeof tab[i] != 'undefined')
{
setTimeout(function(){Affiche(i,tab,id)},1000);
var nombre = document.createTextNode(tab[i]+' ');
document.getElementById(id).appendChild(nombre);
}
}
</script>
</head>
<body onload="Affiche(-1,tab_php1,'mondiv1'),Affiche(-1,tab_php2,'mondiv2'),Affiche(-1,tab_php3,'mondiv3')">
<div id = "mondiv1" style="background:#FF9900"></div>
<div id = "mondiv2" style="background:#FFCCCC"></div>
<div id = "mondiv3" style="background:#FFFFCC"></div>
</body>
</html> |
Partager