Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Łączenie tablic w php
northwest
post
Post #1





Grupa: Zarejestrowani
Postów: 788
Pomógł: 1
Dołączył: 17.09.2004

Ostrzeżenie: (10%)
X----


Witam serdecznie,
Mam 3 tablice:
  1. $testt1 = array(
  2. "thumb" => "thumb1",
  3. "small" => "small1",
  4. "big" => "big1"
  5. );
  6. $testt2 = array(
  7. "thumb" => "thumb2",
  8. "small" => "small2",
  9. "big" => "big2"
  10. );
  11. $testt3 = array(
  12. "thumb" => "thumb3",
  13. "small" => "small3",
  14. "big" => "big3"
  15. );


i chciałbym je połączyć w jedną, aby uzyskać taki efekt:
  1. (
  2. [0] => Array
  3. (
  4. [thumb] => thumb1
  5. [small] => small1
  6. [big] => big1
  7. )
  8.  
  9. [1] => Array
  10. (
  11. [thumb] => thumb2
  12. [small] => small2
  13. [big] => big2
  14. )
  15.  
  16. [2] => Array
  17. (
  18. [thumb] => thumb3
  19. [small] => small3
  20. [big] => big3
  21. )
  22.  
  23. )


Wie ktoś może jak to zrobić?


Z góry dziękuje za pomoc,
Northwest
Go to the top of the page
+Quote Post
Spawnm
post
Post #2





Grupa: Moderatorzy
Postów: 4 069
Pomógł: 497
Dołączył: 11.05.2007
Skąd: Warszawa




Zadeklaruj $tab = array($test1, $test2, $test3);
I tyle smile.gif
A jak coś to masz jeszcze array_push()
Go to the top of the page
+Quote Post
-krzotr-
post
Post #3





Goście







Do wyboru, do koloru

  1. // 1
  2. $t = array_merge(array($testt1), array($testt2), array($testt3));
  3.  
  4. $t = array();
  5.  
  6. // 2
  7. array_push($t, $testt1, $testt2, $testt3);
  8.  
  9. // 3
  10. $t[] = $testt1;
  11. $t[] = $testt2;
  12. $t[] = $testt3;
  13.  
  14. // 4
  15. array_unshift($t, $testt1, $testt2, $testt3);
Go to the top of the page
+Quote Post

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 Aktualny czas: 21.08.2025 - 21:46