title: PHP stop processing 'on button or time 'and output "so far collected array"
body: <p>I have a heavy processing script which can be started from a user via frontend in our intranet. Imagine something like this:</p>
  
  <pre><code>            $html = file_get_contents($url);
              $pattern = '/[A-Z0-9._%+-]+(@|\(at\)|\[at\])[A-Z0-9.-]+\.[A-Z]{2,4}\b/i'; //also (at) and [at]
              preg_match_all($pattern,$html,$emails);
              foreach ($emails[0] as $m)
              {
                  $m[] = $m;
              }
  foreach($m as $n){echo $n."&lt;br&gt;";}
  </code></pre>
  
  <p>This is just an example for illustration of the question! Don't judge it on common sense.</p>
  
  <p>NOW what i want is 2 things:</p>
  
  <ol>
  <li><p>Stop the process on Click on a button from the user. This means: outputting the already collected array $m[].</p></li>
  <li><p>Stop the process (or better: stop the array-collecting process and jump to the echo of the already collected array) based on time (for example max. 1 minute collecting the array, THAN jumping to echoing.</p></li>
  </ol>
  
  <p>I don't want to echo live and setting max execution time will stop the script without echoing. </p>
  
  <p>Thanks for your wise advise on both subquestions</p>