i'm trying to get some random website content for practicing purposes on my localhost. while i'm trying to code this ,i'm getting these two error.
"Warning: file_get_contents(https://www.weather-forecast.com/locations/canada/forecasts/latest): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\weather\weather.php on line 8".
" Undefined offset: 1 in C:\xampp\htdocs\weather\weather.php on line 12" Can anyone let me know what's the issue ? i guess it has something to do with spaces and i checked there isn't any i guess.
here's my code.
if($_GET['city'])
{
$_GET['city'] = str_replace(' ',"",$_GET['city']);
$forecastPage = file_get_contents("https://www.weather-forecast.com/locations/".$_GET['city']."/forecasts/latest");
$pageArray = explode('<span class="b-forecast__table-description-title"><h2>London Weather Today</h2>(1–3 days)</span><p class="b-forecast__table-description-content"><span class="phrase">', $forecastPage);
$secondpagearray = explode('</span></p></td>', $pageArray[1]);
$weather = $secondpagearray[0];
}