Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] "Rozpakowanie" tablicy
Forum PHP.pl > Forum > Przedszkole
Wolfie
Witam,


Mam kilka plikow ktore zawierają w sobie taka tablicę :

  1. Array (
  2. [headers] => Array (
  3. [return-path] => [received] => Array (
  4. [0] => from 129.97.78.23 ([211.202.101.74]) by speedy.uwaterloo.ca (8.12.8/8.12.5)
  5. [1] => from 0.144.152.6 by 211.202.101.74; Sun, 08 Apr 2007 19:04:48 +0100 )
  6. [message-id] => [from] => "Tomas Jacobs"
  7. [reply-to] => "Tomas Jacobs"
  8. [to] => the00@speedy.uwaterloo.ca
  9. ---> [subject] => Generic Cialis, branded quality@
  10. [date] => Sun, 08 Apr 2007 21:00:48 +0300
  11. [x-mailer] => Microsoft Outlook Express 6.00.2600.0000
  12. [mime-version] => 1.0
  13. [content-type] => multipart/alternative; boundary="--8896484051606557286"
  14. [x-priority] => 3
  15. [x-msmail-priority] => Normal
  16. [status] => RO [content-length] => 988
  17. [lines] => 24 )
  18. [starting-pos] => 0
  19. [starting-pos-body] => 772
  20. [ending-pos] => 1761
  21. [ending-pos-body] => 1761
  22. [line-count] => 47
  23. [body-line-count] => 25
  24. [charset] => us-ascii
  25. [transfer-encoding] => 8bit
  26. [content-boundary] => --8896484051606557286
  27. [content-type] => multipart/alternative
  28. [content-base] => / )


Jak widac wyzej zaznaczylem tam [subject] to jest pole do ktorego chce sie dostać

W tym celu stworzylem nastepującą funkcje która wyświetla wszystkie subject z kazdej tablicy z kazdego pliku:

  1. public function getMsgsParts($dir) {
  2. $files = $this->getFiles($dir);
  3. $slice = array_slice($files, 0, 19);
  4. foreach($slice as $filename) {
  5. $mime = mailparse_msg_parse_file($dir.$filename);
  6. $struct = mailparse_msg_get_structure($mime);
  7. //print_r($struct);
  8. foreach($struct as $st) {
  9. $section = mailparse_msg_get_part($mime, $st);
  10. $info = mailparse_msg_get_part_data($section);
  11. $part[] = $info['headers']['subject'];
  12. }
  13. }
  14. return $part;
  15. }


Ale niestety cos jest nie tak z tą funkcja powyzej bo dostaje w efekcie jakies puste pola :
Cytat
Array ( [0] => Generic Cialis, branded quality@ [1] => [2] => [R] Confidence-Intervals.... help... [3] => For Smile [4] => [5] => [6] => Less weight - more pleasure and joy [7] => [8] => [9] => Anatrim will change your life [10] => [11] => [12] => problems in animal studies using rats or rabbits feeding outdoor [13] => [14] => [15] => [16] => [17] => We cure any desease! [18] => [19] => [20] => [21] => [22] => Human Growth Hormone [23] => [24] => [25] => hi man [26] => accelerate it does in adults Older adults?Many medicines have not been [27] => [28] => [29] => [30] => [31] => when taken for a long time or in large doses, but it may cause into [32] => [33] => [34] => [35] => [36] => Typo in /debian/README [37] => Re: [R] Confidence-Intervals.... help... [38] => authentic viagra [39] => [40] => [41] => Array ( [0] => Nice talking with ya [1] => Sorry took so long to get this to ya ) [42] => or trembling; stomach cramps; trouble in sleeping; weakness loose [43] => [44] => [45] => [46] => [47] => Which is duty [48] => [49] => [50] => [51] => [52] => For Theorize [53] => [54] => [55] => Theorize get inside for local esc0rts who do it all [56] => [57] => [58] => [59] => )


Jak widac pierwsze pole zostalo uzupelnione poprawnie, ale juz przy [1] jest pusto a powinno byc to co przy [2]. Itd jak widac dalej tez powstaja puste pola. Powinno byc w sumie 20 pol bo tyle mam wlasnie plikow z tablicami. A kazda tablica w pliku zawiera tylko jedno pole [subject].

Co zrobilem nie tak ?
Jak pozbyc sie pustych pol ?

------------------------------------------------------------

Zrobione - temat do zamkniecia
Fifi209
Obsługuje max 1 zagłębienie

array -> array

a Ty masz array -> array -> array

Przynajmniej z tego co widzę. winksmiley.jpg
Wolfie
ale co obsługuje max 1 zagłebienie ?
Fifi209
Funkcja getMsgsParts winksmiley.jpg
Ma tylko 2 foreach a powinno mieć chyba 3 ew. przepisać funkcję - pomyśl sam.
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.