Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.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获取内容)如何使用foreach循环来删除检索一个字符串_Php_Url_Foreach_File Get Contents - Fatal编程技术网

(php获取内容)如何使用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>' ,

我试图从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;
?>

经过一些研究,我发现了一些联系,但对我没有多大帮助


感谢您的帮助:)

不完全清楚您在这里做了什么。。。是否要获取表单元格(
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);