douzi7219 2017-12-23 17:50
浏览 225
已采纳

为什么找不到div? (simple_html_dom)

I have this code:

<?php
//Include simple_html_dom.php
include('simple_html_dom.php');

//Get function and variable for Webpage
$Flightnumber = '**********';
$firstprelink = '*********************************';
$secondprelink = $Flightnumber;
$fulllink = $firstprelink.$secondprelink;
$html = file_get_html($fulllink, false);
$firstone = $html->find("div[id=********]");
echo $firstone;
?>

Why doesn´t it work ? It should display the div´s of the page. On other webpages it works and when I echo only $html it works fine too. I don´t understand. It just ouputs this:

Notice: Array to string conversion in C:\xampp\htdocs\Sofort-Flug-Entschädigung\simpletest3.php on line 17 Array

  • 写回答

2条回答 默认 最新

  • duanguzhong5776 2017-12-23 21:24
    关注

    So the Solution:

    For some unkown reason I needed to find the div/tag I was searching for by counting it:

    $firstone = $html->find('div');
    $secondone = $firstone[2];
    

    Further: echo; did not work so I used "print();".

    That´s it, so:

    1) Find tag by counting. 2) Print, don´t echo.

    print($secondone);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?