我是PHP的新手,我正试图从预测网站中获取天气摘要数据,我尝试了一切我发现但它只返回Array()
<?php
$contents=file_get_contents("http://www.weather-forecast.com/locations/Podgorica/forecasts/latest");
preg_match('/ <a class="forecast-magellan-target" name="forecast-part-0"><div data-magellan-destination="forecast-part-0"><\/div><\/a><p class="summary"> (.*?) <\/span><\/p> /is',$contents, $matches);
print_r($matches);
?>
答案 0 :(得分:0)
你有额外的空格,请试试这个:
preg_match('/<a class="forecast-magellan-target" name="forecast-part-0"><div data-magellan-destination="forecast-part-0"><\/div><\/a><p class="summary">(.*?)<\/span><\/p>/is',$contents, $matches);