title: Intermittently echo out data with long-running PHP script
body: <p>I have a PHP script that makes a bunch of cURL requests. After each cURL request, I want to echo out some data, but presently, data only gets echoed out after every 5-10 cURL requests.</p>
  
  <p>I've tried using <code>ob_flush</code> and <code>flush</code>, but it doesn't seem to make a difference. The following is the basic flow of my script:</p>
  
  <pre><code>&lt;?php
  
    header('Content-Type: text/html; charset=UTF-8');
  
    set_time_limit(0);
  
    ob_start();
  
    $arr = array(); // Lots of strings in this array
  
    foreach ($arr as $elem) {
  
      // Use $elem to make cURL request and return HTML.
      // Run regexes on returned HTML.
  
      echo '&lt;pre&gt;';
  
      print_r($matches[1]);
  
      print_r($matches[2]);
  
      echo '&lt;/pre&gt;';
  
      ob_flush();
  
      flush();
  
    }
  </code></pre>
  
  <p>Is there anything I can do to force the script to output the echoed/<code>print_r</code>'ed data after each iteration of the foreach loop?</p>
  
  <p>Thank you very much.</p>