Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Prosba o wyjasnienie - funkcja pobierajaca dane, Object PHP
poorman
post
Post #1





Grupa: Zarejestrowani
Postów: 25
Pomógł: 0
Dołączył: 25.11.2009
Skąd: zakopane hej!

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


Witam,
mala prosba dla osob ktore sie znaja na PHP odnosnie tablicy i listy elementow. Dlaczego lista najpierw ma 36 elementow a pozniej po zapisie do tablicy tylko 12? Stoje w miejscu i poprostu tego nie kapuje jak mozna zapisac $this->urlTab[$tag->getAttribute('href')] czyli do tablicy z url ? element tekstu i jeszcze wyrzuci 12 zamiast 36 elementow. pozostale sa puste po jednej stronie czyli $links->item(2)->childNodes->item(0)->nodeValue (KAZDY 3ci jest pelny bo sa 3 linki z ktorych 2 sa puste )
  1. public function getDivById($id){
  2. $this->parsed=parse_url($this->url);
  3. $this->urlTab = array();
  4. $dom = new domDocument;
  5. /*** get the HTML (suppress errors) ***/
  6. @$dom->loadHTML(file_get_contents($this->url));
  7. $dom->preserveWhiteSpace = false;
  8.  
  9. /*** get the links from the HTML ***/
  10. $links = $dom->getElementById($id);
  11. $links = $links->getElementsByTagName('a');
  12. echo $links->length."<br>"; ///////------------- 36 elementow
  13.  
  14. foreach ($links as $tag){
  15. $this->urlTab[$tag->getAttribute('href')]=$links->item(2)->childNodes->item(0)->nodeValue;
  16.  
  17. }
  18. echo count($this->urlTab)."<br>";
  19. echo $this->urlTab->length."--<br>"; ///////------------- 12 elementow


z gory dzieki!

Ten post edytował poorman 21.12.2012, 09:00:25
Go to the top of the page
+Quote Post

Posty w temacie


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: 19.08.2025 - 04:12