(php获取内容)如何使用foreach循环来删除检索一个字符串
我试图从url获取某个表的内容,但它总是得到一个字符串 我想知道是否可以使用foreach循环获取表中的所有字符串,如:(php获取内容)如何使用foreach循环来删除检索一个字符串,php,url,foreach,file-get-contents,Php,Url,Foreach,File Get Contents,我试图从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>' ,
<?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;
?>
经过一些研究,我发现了一些联系,但对我没有多大帮助
感谢您的帮助:)不完全清楚您在这里做了什么。。。是否要获取表单元格(
xxx
)之间所有字符串的内容
$url='1!'https://www.w3.org/WAI/UA/2002/06/thead-test';
$content=file\u get\u contents($url);
preg#u match_all(“#(.*?)#m”,$content,$matches);
$output=$matches[1];
变量转储(输出);
是。但我做不到。即使您的代码也不成功:/比方说获取此url的内容。我想从一个太五的叫声中得到x之间的所有字符串;很抱歉preg_match_all构建matches数组的方式总是让我感到惊讶。以上已编辑并修复。谢谢。你能用普通的txt输出吗?echo内爆(“”,$matches[1])代码>
$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);