Try a function for a certain amount of time then give up -- php
<p>I hit external data sources in my php script, but would like to give up if it takes a while. Something along the lines of:</p>

<pre><code>&lt;?php

  try_for_500_ms {
    load_data_from_external_database();
  }
  catch_if_took_longer_than_500ms {
    echo 'Took too long to load data';
  }
</code></pre>

<p>In other words, I want it to give up trying to load the external data after a set amount of time and continue the script. Any ideas how to implement something like that? Thanks in advance.</p>
