title: Optimizing a file_get_contents() script from a .json URL
body: <p>I need help for my code. I'm getting content from a .JSON file (URL) and I'm trying to optimize it because it's loading too slow. So i have the following code:</p>
  <pre><code>&lt;?php 
  $site = file_get_contents('website.com/content.json');
  $obj = json_decode($site, true);
  
  for ($i = 0; $i &lt;= 9; $i++) {
      echo '&lt;div class=&quot;result-' . $obj[$i]['id'] . '&quot;&gt;&lt;/div&gt;';
  } 
  ?&gt;
  </code></pre>
  <p>so everything looks fine, right? But here comes the hard part. In this simple loop I need to create another URL request so I can get information about the current result from another URL. Here we go:</p>
  <pre><code>&lt;?php 
  $site = file_get_contents('website.com/content.json');
  $obj = json_decode($site, true);
  
  for ($i = 0; $i &lt;= 9; $i++) {
      echo '&lt;div class=&quot;result-' . $obj[$i]['id'] . '&quot;&gt;';
      $info = json_decode(file_get_contents(&quot;website.com/info/&quot; . $obj[$i]['id'] . &quot;.json), true);
      echo $info['content'];
      echo '&lt;/div&gt;';
  } 
  ?&gt;
  </code></pre>
  <p>so that leads to much slower page load because of the many queries that needs to be ran. Any idea what to do? (I can't keep the additional info in single storage. It must be on different URL)</p>