Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用PHP简单html dom获取特定的表单元格值_Php_Html Parsing_Simple Html Dom - Fatal编程技术网

如何使用PHP简单html dom获取特定的表单元格值

如何使用PHP简单html dom获取特定的表单元格值,php,html-parsing,simple-html-dom,Php,Html Parsing,Simple Html Dom,现在我想得到(163)的最后一个值。您已经更新了您的问题,因此,在更新的问题的基础上,您也可以使用此代码 head1 head2 head3 head4 head5 row1 0 0 0 0 155 row2 0 0 0 0 8 row3 0 0 0 0 163 您需要PHP简单HTML DOM解析器library执

现在我想得到(163)的最后一个值。

您已经更新了您的问题,因此,在更新的问题的基础上,您也可以使用此代码

             head1 head2 head3 head4 head5
       row1     0    0     0     0    155
       row2     0    0     0     0      8
       row3     0    0     0     0    163
您需要
PHP简单HTML DOM解析器
library执行此操作并下载

您可以像这样包含文件

//$url is your path
$j = new simple_html_dom();
$j = file_get_html($url);

foreach($j->find('table tr') as $row) {
    $cell = $row->find('td', 0);
    echo $cell;
}
以下是完整的文档

对于特定的单元格,可以使用

 require_once 'simple_html_dom.php';

我认为您应该阅读
HTMLDOM解析器手册
。有多种方法可以获取childNodes

致命错误:在null上调用成员函数find()in@Karthik我已经更新了下面代码中使用的答案,如果您发现任何错误,请更新我。我再次遇到同样的问题,我已经得到了整个表格数据,但我只需要特定的表格单元格(163)。请查看示例表record.echo$html->find(“#table_id”,0)->children(1)->children(1)->children(2)->id;在basic中,如何在不使用任何id或类的情况下从表中获取准确值。请分享您迄今为止的尝试,并更加具体,以便我们知道您需要帮助的代码部分。此外,确定输入HTML的准确结构是一种猜测工作,因为您只提供呈现结果。
// Example
echo $html->find("#table_id", 0)->children(1)->children(1)->children(2)->id;
// or 
echo $html->getElementById("table_id")->childNodes(1)->childNodes(1)->childNodes(2)->getAttribute('id');