I am trying to search url pages for a search term and grab some text around the search term. The seed url's are in a large database. For some reason it hangs on a few sites. Here is one site it usually hangs on: http://www.ravencruise.com/logbooks.htm Is there a way to time out file_get_contents()?
You can try adding the following somewhere above your file_get_contents call: ini_set('default_socket_timeout', #); PHP: Replace # with a new number to set it to. I am not really sure what numbers it uses by defaults and such however you can call this function first to check what it currently is: $current_timeout = ini_get('default_socket_timeout'); PHP: By setting the value lower, it will only affect it for the current script run, and it will cause it to timeout sooner. Hopefully it works for you. You can also, if your host allows it, create a php.ini file in the same directory as the script and place the following in it: default_socket_timeout = # Again, replacing # with a new value.