Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Pętla for
thurinon
post
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 2
Dołączył: 8.10.2009

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


Witam serdecznie :-) Mam pytanko jak skrócić ten kod. Mam na myśli samą pętle. Chodzi o To aby stworzyć kwadrat składający się z 36 mniejszych kwadratów. Ten kod działa, ale wydaje mi się że za pomocą ifa można by to skrócić, ale to ifowanie mi nie wychodzi.

  1. for($c=0; $c 0= 5; $c++)
  2. {
  3. echo '<div style="border: 1px solid #'.$paleta2[''.$c.''].'; background-color: #'.$paleta2[''.$c.''].';width: 20px; height: 20px; float: left; display: block;"></div>';
  4. }
  5.  
  6. echo'<div style="clear: both;"</div>';
  7. for($c=6; $c = 11; $c++)
  8. {
  9. echo '<div style="border: 1px solid #'.$paleta2[''.$c.''].'; background-color: #'.$paleta2[''.$c.''].';width: 20px; height: 20px; float: left; display: block;"></div>';
  10. }
  11. echo'<div style="clear: both;"</div>';
  12. for($c=12; $c = 17; $c++)
  13. {
  14. echo '<div style="border: 1px solid #'.$paleta2[''.$c.''].'; background-color: #'.$paleta2[''.$c.''].';width: 20px; height: 20px; float: left; display: block;"></div>';
  15. }
  16. echo'<div style="clear: both;"</div>';
  17. for($c=18; $c = 23; $c++)
  18. {
  19. echo '<div style="border: 1px solid #'.$paleta2[''.$c.''].'; background-color: #'.$paleta2[''.$c.''].';width: 20px; height: 20px; float: left; display: block;"></div>';
  20. }
  21. echo'<div style="clear: both;"</div>';
  22. for($c=24; $c = 29; $c++)
  23. {
  24. echo '<div style="border: 1px solid #'.$paleta2[''.$c.''].'; background-color: #'.$paleta2[''.$c.''].';width: 20px; height: 20px; float: left; display: block;"></div>';
  25. }
  26. echo'<div style="clear: both;"</div>';
  27. for($c=30; $c = 35; $c++)
  28. {
  29. echo '<div style="border: 1px solid #'.$paleta2[''.$c.''].'; background-color: #'.$paleta2[''.$c.''].';width: 20px; height: 20px; float: left; display: block;"></div>';
  30. }


Jak zawsze z góry dzięki za pomoc, i pozdrawiam :-)

Ten post edytował thurinon 21.11.2010, 15:50:41
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 14.09.2025 - 17:21