我试图从url中获取一些表的内容,但它总是得到一个字符串。
我想知道是否可以使用foreach循环来获取表中的所有字符串,如下所示:
<?php
$url = 'https://www.w3.org/WAI/UA/2002/06/thead-test';
$content = file_get_contents($url);
$first_step = explode( '<td>' , $content );
$second_step = explode('</td>' , $first_step[1] );
$output = $second_step[0];
echo $output;
?>
我在一些研究后找到了一些链接,但它对我帮助不大。
如有任何帮助,我们将非常感谢:)
发布于 2018-08-26 06:11:11
不完全清楚你在这里做什么.您想获取表单元格之间的所有字符串的内容(<td>xxx</td>
)吗?
$url = 'https://www.w3.org/WAI/UA/2002/06/thead-test';
$content = file_get_contents($url);
preg_match_all('#<td>(.*?)</td>#m', $content, $matches);
$output = $matches[1];
var_dump($output);
https://stackoverflow.com/questions/52020889
复制相似问题