title: failed to open stream: HTTP request failed! HTTP/1.1 404
body: <p>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.</p>
  
  <ol>
  <li><p>"Warning: file_get_contents(<a href="https://www.weather-forecast.com/locations/canada/forecasts/latest" rel="nofollow noreferrer">https://www.weather-forecast.com/locations/canada/forecasts/latest</a>): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\weather\weather.php on line 8".</p></li>
  <li><p>" 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.</p></li>
  </ol>
  
  <p>here's my code. </p>
  
  <pre><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('&lt;span class="b-forecast__table-description-title"&gt;&lt;h2&gt;London Weather Today&lt;/h2&gt;(1&amp;ndash;3 days)&lt;/span&gt;&lt;p class="b-forecast__table-description-content"&gt;&lt;span class="phrase"&gt;', $forecastPage);
      $secondpagearray = explode('&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;', $pageArray[1]);
      $weather = $secondpagearray[0];
  }
  </code></pre>