Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.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 返回所有td值的简单html dom解析器?_Php_Php 5.3 - Fatal编程技术网

Php 返回所有td值的简单html dom解析器?

Php 返回所有td值的简单html dom解析器?,php,php-5.3,Php,Php 5.3,我正在使用简单的html dom解析器从html字符串中获取一些数据。 我需要从带有特定css类的表中返回TD值,每个TD作为数组元素 我试过这种鳕鱼,但它有胎儿的错误 <?php include('classes/simple_html_dom.php'); $html = str_get_html('<table class="pages_navigator"> <tr> <th style="width:50px;">ID </th>

我正在使用简单的html dom解析器从html字符串中获取一些数据。
我需要从带有特定css类的表中返回TD值,每个TD作为数组元素
我试过这种鳕鱼,但它有胎儿的错误

<?php
include('classes/simple_html_dom.php');
$html = str_get_html('<table class="pages_navigator">
<tr>
<th style="width:50px;">ID </th>
<th>Business </th>
<th style="width:70px;">Category</th>
<th style="width:50px;">Phone </th>
<th style="width:70px;">State</th>
<th style="width:70px;">City</th>
<tr class="users_tr">
<td>3571</td>
<td>Premium GD</td>
<td>2063199876</td>
<td>Washington</td>
<td>Seattle</td>
<td>3703</td>
</tr>
</table>');
$tds = $html->find('table.pages_navigator')->find('td') ;
print_r($tds);
?>

将您的查询从

foreach($html->find('tr.users_tr') as $e){


这应该允许您遍历所有td,而不是获取整行的纯文本

请添加打印$result的内容?您是否可以使用var_dump($e)?@drneo哪种变体有效。。。我将从答案中删除没有删除的一个。第一个foreach($html->find('tr.users\u tr td')作为$e{谢谢
Array ( 
[0] => 3571 Premium GD 2063199876 Washington Seattle 3703 
)
foreach($html->find('tr.users_tr') as $e){
foreach($html->find('tr.users_tr td') as $e){