View Single Post
Old 12-05-2003, 09:27 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,530
sde is on a distinguished road
file() and setting a timeout

i have a site where i pull a file in remotely from another url. for example:
PHP Code:
<?
$array 
file("http://somehost/somefile.txt");

foreach(
$array as $each)
{
  echo 
"$each <br>\n";
}
?>
sometimes it is possible that this remote file will not be available. if it is not available, the code above will cause the page to hang, and then print an error.

i want it to spend 1 second max checking for this file, .. and if it doesn't find it, then print "not available"

what would be the best way to go about this? maybe using curl? is there any other way?
__________________
Mike
sde is offline   Reply With Quote