Je cherche a faire une espèce de machine a sous, j'ai 5 images qui s'affiche aléatoirement, voilà pour la partie simple.
- Première question j'arrive à afficher mes images aléatoirement, à dire que seulement si l'image 4 apparaît trois fois alors c'est gagné, mais je pense que mon code doit être nul il doit y avoir un méthode beaucoup plus simple et moin sauvage?
Merci
Code :
- <?php
- $img[1]="1.png";
- $img[2]="2.png";
- $img[3]="3.png";
- $img[4]="4.png";
- $img[5]="5.png";
- mt_srand(time());
- $num1=rand(1,5);
- $num2=rand(1,5);
- $num3=rand(1,5);
- ?>
- <img src="/ga/img/<?php echo $img[$num1];?>" border=0 width=100 height=47 alt="0">
- <img src="/ga/img/<?php echo $img[$num2];?>" border=0 width=100 height=47 alt="0">
- <img src="/ga/img/<?php echo $img[$num3];?>" border=0 width=100 height=47 alt="0">
- <?php
- if($num1 == 4 && $num2 == 4 && $num3 == 4)
- {
- print("<BR>!! Bingo !!" );
- exit;
- }
- ?>
|