I want to repeatedly check a variable every time php wakes up from sleep(). Further, if 3 minutes have passed without finding a particular variable then the function should stop checking. How would I go about this? This is the code I have thus far:
<?php
$file = file_get_contents("file.txt");
if($file == 0){
sleep(3);// then go back to $file
} else {
//stuff i want
}
?>
If you want to keep doing something until something else happens, you want a loop. You have two things to check to see if you should exit the loop: the file variable and the length of time. You need to add a variable to keep track of the time, or you need to check the time each time you loop and compare it to the start time.