I am trying to build a weather scraper app. For some reason, this php code gives me error
$city = $_GET['city'];
$city = str_replace(" ","",$city);
$contents = file_get_contents("http://www.weather-forecast.com/locations/".$city."/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); //use single quotes ' " " ' if double quotes are inside
echo($matches[0]);
Which is giving me following error if I don't enter city = new york, and if I spell wrong city name it gives me same error coz $city
is empty of has a wrong value.. is there any way to fix it?