The following code breaks once every 36 hours at a random time. The correctness of info.txt is assured. A simple print 'test'; or sleep(1); between the lines of $handle and while works around the problem, but why?
$handle = fopen("http://www.domain.do/info.txt", "r");
while (!feof($handle)) {
// [do stuff]
}
fclose ($handle);
The code is run by a cron job.
Adding the sleep() or some delay will give the fopen time to retrieve the file from the location… I am presuming the ‘random’ effect may be traffic on the network causing retrieval to be slightly longer than usual.
You could try to use cURL to retrieve data:
$outputwill contain the contents of the file, so you would need to split the string into an array possibly using newline as delimiter… only guessing don’t know the content of the file 🙂