title: PHP exceptions in foreach loop
body: <p>Which is the right way to implement php exception (try{}catch(){}) in a foreach loop that looks like this:</p>
  
  <pre><code>foreach ($apis as $api)
  {                 
       $api = '_'.$api;
       $searchResults[$api] = $this-&gt;$api($parameters);
  }
  </code></pre>
  
  <p>I want to implement the php exceptions for if one of the <strong>$this->api();</strong> returns an error message, than catch it and do a if inside the catch to display the right message for the error message returned.</p>
  
  <p>Edit:
  Also, when capturing the error and if the error message is 1 (for example) is it a good way to do:</p>
  
  <pre><code>$searchResults['api'] = $this-&gt;_api($parameters);
  </code></pre>
  
  <p>so it tries to do the function again and see if this time it brings valid data?</p>