Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Głębokie menu
Tsiru
post
Post #1





Grupa: Zarejestrowani
Postów: 213
Pomógł: 0
Dołączył: 7.01.2005
Skąd: Nigdzie

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


Witam !
Mam problem ze skryptem, a mianowicie mam taką tabliczke:
Kod
Array ( [0] => Array ( [data] => Array ( [name] => gry ) [0] => Array ( [data] => Array ( [name] => sh ) [0] => Array ( [data] => Array ( [name] => wstęp ) ) [1] => Array ( [data] => Array ( [name] => kody ) ) [2] => Array ( [data] => Array ( [name] => solucja ) ) ) [1] => Array ( [data] => Array ( [name] => re ) [0] => Array ( [data] => Array ( [name] => wstep ) ) [1] => Array ( [data] => Array ( [name] => kody ) ) [2] => Array ( [data] => Array ( [name] => opis ) ) [3] => Array ( [data] => Array ( [name] => solucja ) [0] => Array ( [data] => Array ( [name] => leon ) [0] => Array ( [data] => Array ( [name] => leonA ) ) [1] => Array ( [data] => Array ( [name] => leonB ) ) ) [1] => Array ( [data] => Array ( [name] => claire ) [0] => Array ( [data] => Array ( [name] => claireA ) ) [1] => Array ( [data] => Array ( [name] => claireB ) ) ) [2] => Array ( [data] => Array ( [name] => tofu ) ) ) ) [2] => Array ( [data] => Array ( [name] => re2 ) [0] => Array ( [data] => Array ( [name] => index ) ) [1] => Array ( [data] => Array ( [name] => kody ) ) [2] => Array ( [data] => Array ( [name] => opis ) ) [3] => Array ( [data] => Array ( [name] => solucja ) ) ) [3] => Array ( [data] => Array ( [name] => re3 ) [0] => Array ( [data] => Array ( [name] => różno�ci ) ) [1] => Array ( [data] => Array ( [name] => cuda ) ) [2] => Array ( [data] => Array ( [name] => bajery ) ) ) ) [1] => Array ( [data] => Array ( [name] => home ) [0] => Array ( [data] => Array ( [name] => news ) ) [1] => Array ( [data] => Array ( [name] => ksiega go�ci ) ) [2] => Array ( [data] => Array ( [name] => porady ) ) ) )
i skrypt który ją wyświetla w formie katalogów:
  1. <?php
  2. for($a = 0; $a < count($f);$a++)
  3. {
  4. echo('<A><img src="http://images.google.pl/images?q=tbn:eiOfx2cxheQJ:http://www.ubiobio.cl/~gpoo/icons/crux/gnome-mime-directory-dir.png" align="middle" height="20" width="29" border="0" />'.$f[$a]['data']['name']."</A><br />n");
  5. for($a1 = 0; $a1 < count($f[$a]) - 1;$a1++)
  6.  {
  7. echo('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A><img src="http://images.google.pl/images?q=tbn:eiOfx2cxheQJ:http://www.ubiobio.cl/~gpoo/icons/crux/gnome-mime-directory-dir.png" align="middle" height="20" width="29" border="0" />'.$f[$a][$a1]['data']['name']."</A><br />n");
  8. for($a2 = 0; $a2 < count($f[$a][$a1]) - 1;$a2++)
  9.  {
  10.  echo('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A><img src="http://images.google.pl/images?q=tbn:eiOfx2cxheQJ:http://www.ubiobio.cl/~gpoo/icons/crux/gnome-mime-directory-dir.png" align="middle" height="20" width="29" border="0" />'.$f[$a][$a1][$a2]['data']['name']."</A><br />n");
  11.  for($a3 = 0; $a3 < count($f[$a][$a1][$a2]) - 1;$a3++)
  12. {
  13. echo('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A><img src="http://images.google.pl/images?q=tbn:eiOfx2cxheQJ:http://www.ubiobio.cl/~gpoo/icons/crux/gnome-mime-directory-dir.png" align="middle" height="20" width="29" border="0" />'.$f[$a][$a1][$a2][$a3]['data']['name']."</A><br />n");
  14. for($a4 = 0; $a4 < count($f[$a][$a1][$a2][$a3]) - 1;$a4++)
  15.  {
  16.  echo('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A><img src="http://images.google.pl/images?q=tbn:eiOfx2cxheQJ:http://www.ubiobio.cl/~gpoo/icons/crux/gnome-mime-directory-dir.png" align="baseline" height="20" width="29" border="0" />'.$f[$a][$a1][$a2][$a3][$a4]['data']['name']."</A><br />n");
  17. }
  18. }
  19. }
  20. }
  21. }
  22. ?>

Ale jeżeli zaglębienie jest większe niż 4 poziomy, menu się nie wyświetli, a dopisywanie kolejnych pętęlek for() da zawsze ograniczoną głębokość drzewka.
Jak to zrobić, żeby efekt wyświetlania był taki sam, a żeby nie było limitu kłębokości drzewka ?

Ten post edytował Tsiru 20.09.2005, 07:56:08
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


Poczytaj o rekurencji.
Pomoże Ci też artykuł Drzewka w php.
Go to the top of the page
+Quote Post
Tsiru
post
Post #3





Grupa: Zarejestrowani
Postów: 213
Pomógł: 0
Dołączył: 7.01.2005
Skąd: Nigdzie

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


Dzięki za arta.

A czy możesz mi wytłumaczyć, czym są klasy na jakiej zasadzie działają, bo z tego co jest napisane w kursach niewiele rozumiem (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
Alchemy_A.R.T.
post
Post #4





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 3.09.2005

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


sciagnij sobie mygosu menu (chyba z gosu.pl) i tam w jednym katalogu jest wlasnie taka funkcja - niestety nie mam teraz tego na dysiorku wiec ci nie wkleje
Go to the top of the page
+Quote Post
luinnar
post
Post #5





Grupa: Zarejestrowani
Postów: 155
Pomógł: 0
Dołączył: 15.07.2004
Skąd: Bielsko-Biała

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


Cytat(Tsiru @ 2005-09-20 16:57:57)
A czy możesz mi wytłumaczyć, czym są klasy na jakiej zasadzie działają, bo z tego co jest napisane w kursach niewiele rozumiem  (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)

myślę że TO może ci się przydać jest tam wiele cennych informacji o OOP (programowaniu obiektowym).
Go to the top of the page
+Quote Post
hwao
post
Post #6


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




ale do rekurencji mozna uzyc funkcji.
Go to the top of the page
+Quote Post

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: 24.08.2025 - 10:23