title: Can I throw exception in a for loop , if memory exceeds in that loop
body: <p>How can I handle an exception happening in a foreach loop?</p>
  
  <p>I want to throw my exception if the for loop didn't work properly.</p>
  
  <p>As data is huge, foreach exits because PHP's memory limit is exceeded.</p>
  
  <pre><code>try
  {
   foreach()
  }catch (exception $e)
  
  {
  echo $e;
  }
  </code></pre>
  
  <p>This is not working. How do I throw an exception?</p>