Php 在网站上使用preg_match访问信息时返回空数组

Php 在网站上使用preg_match访问信息时返回空数组,php,Php,我正在尝试访问php文件中天气页面的一些内容。该网站是:在查看来源,我想能够获得信息:“3天天气预报摘要:”和所有必要的信息在那里 到目前为止,我的代码是: <?php $contents = file_get_contents("http://www.weather-forecast.com/locations/Bergen/forecasts/latest"); preg_match('/3 Day Weather Forecast Summary:<\/b&

我正在尝试访问php文件中天气页面的一些内容。该网站是:在查看来源,我想能够获得信息:“3天天气预报摘要:”和所有必要的信息在那里

到目前为止,我的代码是:

<?php

    $contents = file_get_contents("http://www.weather-forecast.com/locations/Bergen/forecasts/latest");

    preg_match('/3 Day Weather Forecast Summary:<\/b><span class="read-more-small"><span class="read-more-content"> <span class="phrase"> (.*?) </s', $contents, $matches);
    print_r($matches);

?>

据我所知,您的正则表达式不应该在通配符匹配周围包含空格,因为网站源代码在3天摘要前后都没有空格。尝试:

'... <span class="phrase">(.*?)</s'

”。。。(*)我不太确定我是否完全理解你的意思。你的意思是删除所有空格吗?例如:赛前('/3天天气预报摘要:(.*)非常感谢!确实有效!我如何将您的答复标记为解决方案?@stAMy我的答案旁边应该有一个复选标记,单击它。:)
preg_match(
    '/3 Day Weather Forecast Summary:<\/b><span class="read-more-small"><span class="read-more-content"> <span class="phrase">(.*?)</s',
    $contents,
    $matches
  );