Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Jak sprawdzić czy tablica jest wielowymiarowa?
eai
post
Post #1





Grupa: Zarejestrowani
Postów: 367
Pomógł: 10
Dołączył: 20.05.2005

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


Witam.

  1. <?php
  2.  
  3. $array = array ('Test Value 1','Test Value 2','Test Value 3','Test Value 4');
  4. $array2 = array ('Test Value 5','Test Value 6','Test Value 7','Test Value 8');
  5.  
  6. $test['arrays']['array1'] = $array;
  7. $test2['array2'] = $array2;
  8.  
  9. ?>


Chodzi mi o to że mam np funcje foo($parm); gdzie $parm to tablica. Ale nie wiadomo ilo jest wymiarowa.
W jaki sposób w łatwy sposób sprawdzić ile zawiera podelementów.

Jak narazie mam tylko jedno rozwiązanie foreach() + if() + is_array();
Czyli robie pętle aż do rozbicia wszystkich elementów.

Ale może istnieje jakiś łatwiejszy sposób questionmark.gif

Pzdr.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
Cysiaczek
post
Post #2





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




Wydaje się, że to jest rozsądne rozwiazanie i nie ma po co go zmieniać.

Pozdrawiam


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
eai
post
Post #3





Grupa: Zarejestrowani
Postów: 367
Pomógł: 10
Dołączył: 20.05.2005

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


No niby tak ale musze robić $array => foreach =>is_array($value) foreach => is_array($value) foreach => is_array($value) i tak w nieskonczonsc. Moze jest lepszy sposób questionmark.gif dry.gif

Ten post edytował eai 8.08.2006, 18:26:02
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 - 22:44