Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Uproszczenie pętli
Dariusz_512
post 10.01.2009, 22:35:41
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 2.04.2007

Ostrzeżenie: (0%)
-----


Mam kod

  1. <?
  2.  
  3. while(($num == $num1) or ($num == $num2) or ($num == $num3) or ($num == $num4) or ($num == $num5) or ($num1 == $num2) or ($num1 == $num3) or ($num1 == $num4) or ($num1 == $num5) or ($num2 == $num3) or ($num2 == $num4) or ($num2 == $num5) or ($num3 == $num4) or ($num3 == $num5) or ($num4 == $num5))
  4.    {
  5.    $num = rand(1,6);
  6.    $num1 = rand(1,6);
  7.    $num2 = rand(1,6);
  8.    $num3 = rand(1,6);
  9.    $num4 = rand(1,6);
  10.    $num5 = rand(1,6);
  11. }
  12.  
  13. echo $num.'</br>';
  14. echo $num1.'</br>';
  15. echo $num2.'</br>';
  16. echo $num3.'</br>';
  17. echo $num4.'</br>';
  18. echo $num5.'</br>';
  19.  
  20. ?>


Nie da się prościej ? smile.gif

Chodzi oczywiście tylko o ustawienie 6 liczb, od "1" do "6" w losowej kolejności.

Ten post edytował Dariusz_512 10.01.2009, 22:42:53
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 11:54