Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Tablice, pomózcie to przetworzyc
Forum PHP.pl > Forum > PHP
dsk
Hej,

Mam taką tablicę:
  1. <?php
  2. Array ( 
  3. [1] => 
  4.  Array ( 
  5. [2] => 
  6.  Array ( 
  7. [1] => Array ( [username] => testtest [name] => testtest [email] => testtest [type] => Standard [joined] => 2007-04-05 [stats] => No deposit yet ) 
  8. [2] => Array ( [username] => aus [name] => aus [email] => 123 [type] => Super VIP [joined] => 2007-04-05 [stats] => Deposited ) 
  9. [3] => Array ( [username] => 1st [name] => 1st [email] => 123 [type] => Super VIP [joined] => 2007-04-05 [stats] => Deposited ) 
  10. [4] => Array ( [username] => we [name] => we [email] => we [type] => Super VIP [joined] => 2007-04-05 [stats] => No deposit yet ) 
  11. [5] => Array ( [username] => test1 [name] => test1 [email] => test1@test.com [type] => Super VIP [joined] => 2007-04-04 [stats] => No deposit yet )
  12.  ) )
  13. [2] => Array ( [12] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => aus.[type] => VIP [joined] => 2007-04-
  14. 05 [stats] => Deposited ) [2] => Array ( [username] => fortest [name] => fortest [email] => 123 [type] => VIP [joined] => 2007-04-05 [stats] => No deposit yet ) ) [18] => Array ( [4] => Array ( [username] => 2nd [name] => 2nd [email] => 12 [type] => Platinum [joined] => 2007-04-05 [stats] => Deposited ) ) [3] => Array ( [6] => Array ( [username] => test2 [name] => test2 [email] => test2@asd.com [type] => Standard [joined] => 2007-04-04 [stats] => No deposit yet ) ) ) [3] => Array ( [13] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => aus.[type] => Platinum [joined] => 2007-04-05 [stats] => Deposited ) ) [19] => Array ( [5] => Array ( [username] => 3rd [name] => 3rd [email] => 123 [type] => Gold [joined] => 2007-04-05 [stats] => Deposited ) ) [4] => Array ( [7] => Array ( [username] => test4 [name] => test4 [email] => test4@asd.com [type] => Standard [joined] => 2007-04-04 [stats] => No deposit yet ) [8] => Array ( [username] => test3 [name] => test3 [email] => test3@asda.com [type] => Standard [joined] => 2007-04-04 [stats] => No deposit yet ) ) ) [4] => Array ( [14] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => aus.[type] => Platinum [joined] => 2007-04-05 [stats] => Deposited ) ) [20] => Array ( [6] => Array ( [username] => 4th [name] => 4th [email] => 123 [type] => Gold [joined] => 2007-04-05 [stats] => Deposited ) [7] => Array ( [username] => 3rdreferral [name] => 3rdreferral [email] => 123 [type] => Gold [joined] => 2007-04-05 [stats] => No deposit yet ) ) [6] => Array ( [8] => Array ( [username] => test5 [name] => Test5 Name [email] => test5@test.com [type] => Standard [joined] => 2007-04-05 [stats] => No deposit yet ) ) ) [5] => Array ( [15] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => aus.[type] => Platinum [joined] => 2007-04-05 [stats] => Deposited ) ) [21] => Array ( [7] => Array ( [username] => 5th [name] => 5th [email] => 123 [type] => Bronze [joined] => 2007-04-05 [stats] => Deposited ) [8] => Array ( [username] => 3rd123 [name] => 3rd123 [email] => 123 [type] => Bronze [joined] => 2007-04-05 [stats] => No deposit yet ) ) ) [6] => Array ( [16] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => aus.[type] => Platinum [joined] => 2007-04-05 [stats] => Deposited ) ) [22] => Array ( [8] => Array ( [username] => 6th [name] => 6th [email] => 123 [type] => Bronze [joined] => 2007-04-05 [stats] => Deposited ) ) ) [7] => Array ( [17] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => 123 [type] => Platinum [joined] => 2007-04-09 [stats] => Deposited ) ) [23] => Array ( [9] => Array ( [username] => 7th [name] => 7th [email] => 123 [type] => VIP [joined] => 2007-04-05 [stats] => Deposited ) ) ) [8] => Array ( [100127] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => 123 [type] => Platinum [joined] => 2007-04-09 [stats] => Deposited ) ) ) [9] => Array ( [100128] => Array ( [1] => Array ( [username] => aus.[name] => aus.[email] => 123 [type] => Platinum [joined] => 2007-04-09 [stats] => Deposited ) ) ) )
  15. ?>


Najpierw pobieram elementy z bazy, przetwarzam to i wsadzam do takiej tablicy.
Nie znalazłem innego sposobu niz tablica w takiej formie jakiej aktualnie jest, jest to dosyc skomplikowane.

Niestety, próbowałem to przetworzyć i wyświetlić, ale wszystko jest źle wyswietlane, nie za bardzo mam pojecie jak mozna to szybko i dobrze przetworzyc
Tym bardziej ze to trzeba przetwarzac rekurencyjnie

Głownie to chodzi o to zeby wypisac username i poleconych ponizej (tak jak w programach partnerskich)
- username
- username1
--- username142
----- username150
- username12
--- username190
----- username202
------- username122
--- username143
- username111

Bardzo prosze o pomoc, nie mam za bardzo doswiadczenia z wielowymiarowymi tablicami
starach
Chętnie pomogę ale przetwórz dane z tej tablicy na takie które da się przeczytać. Nie test x tylko User1 nie agf tylko normalny adres email.
I potem napisz co chcesz osiągnąć bo wybacz ale nie będę się domyślał która wartość z tablicy jest którą w twoim drzewku wynikowym.
piczu
  1. <?
  2. function usertree($array) {
  3. foreach($array as $key => $value) {
  4. if(is_array($value)) usertree($value);
  5. else echo $key." => ".$value."n";
  6. }
  7. }
  8. ?>

to by bylo cos takiego
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.