title: foreach loop running through curl function
body: <p>I've been scratching my head for days over this stupid one.</p>
  
  <p>I have an array of urls called $url_array pulled from the database like so -</p>
  
  <pre><code>Array (
      [id] =&gt; 2
      [url] =&gt; http://example.com
  )
  </code></pre>
  
  <p>I have foreach loop which runs over $url_array and scrapes the url for data like so -</p>
  
  <pre><code>foreach ($url_array as $row) {
      $data = $this-&gt;scrapePage($row["url"]);
      print_r($data);
      return false;
  }
  </code></pre>
  
  <p>Currently $data is outputting nothing. But if I replace $row["url"] with <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a>, the scrape happens correctly.</p>
  
  <p>This is the first time I've also hosted this script on DigitalOcean so I'm not sure if there are any server technicalities possibly stopping a foreach loop from working.</p>
  
  <p>edit:
  Here is the scrapePage function -</p>
  
  <pre><code>private function scrapePage($url) {
      $ch = curl_init($url);
  
      curl_setopt($ch, CURLOPT_COOKIESESSION, true);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Charset: utf-8'));
      curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
      curl_setopt($ch, CURLOPT_VERBOSE, true);
  
      $content = curl_exec($ch);
      $header = curl_getinfo($ch);
      curl_close($ch);
  
      return array("header" =&gt; $header, "content" =&gt; $content);
  }
  </code></pre>
  
  <p>Like I said, if I manually enter a url in there, it works fine, just not when in a loop.</p>
  
  <p>As for the $url_array, this is the output when I print it out -</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 41
              [url] =&gt; http://www.example1.com
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 85
              [url] =&gt; http://test-url-2.com
          )
  )
  </code></pre>
  
  <p>I've also tried a for loop over the data. If I modify the scrapePage function to return the $url, it returns the $url correctly.</p>