【发布时间】:2014-11-26 16:21:00
【问题描述】:
我有问题。我需要得到这样的页面的一些行:
Text text text ...
Porto-Portugal-May-2013
Barcelona-Spain-April-2013
Text text text text text ...
Madrid-Spain-April-2013
Text text text ...
我需要过滤器,以便只显示以下内容:
Porto-Portugal-May-2013
Barcelona-Spain-April-2013
Madrid-Spain-April-2013
(带有 3 个破折号的行)
preg_match_all 或者其他函数可以吗?
我使用 cURL 来获取页面内容。
我试过了:
$body = " Text text text ...
Porto-Portugal-May-2013
Barcelona-Spain-April-2013
Text text text text text ...
Madrid-Spain-April-2013
Text text text ...";
preg_match_all("/^(.*?)-(.*?)-(.*?)-(.*?)\/",$body, $match);
for($i=0;$i<sizeof($match[1]);$i++)
{
echo $match[1][$j].'<br/>';
}
谢谢。
【问题讨论】:
-
请分享您的尝试。 SO 不是编码服务。
-
我已经用示例更新了问题。谢谢。
-
你得到的结果有什么问题?
-
它不返回结果。它是空的......
标签: php regex curl preg-match preg-match-all