Answer the question
In order to leave comments, you need to log in
How can I make the service add 1 word per page every minute?
Hi all. There is a completely blank page, how to make it add 1 random word from the list every minute? Service time from a week, with page cleaning after a certain number of words.
There is no cron on the hosting.
Answer the question
In order to leave comments, you need to log in
In this case, words with a period of 3 seconds
<?
$period = 3;
if (file_exists("last_time")) {
$last_time = @file_get_contents("last_time");
$current_time = time();
} else {
$current_time = time();
$last_time = $current_time-$period;
}
$steps = floor(($current_time - $last_time) / $period);
if ($steps > 0) {
$words_list = array("слово 1", "слово 2", "слово 3", "слово 4", "слово 5", "слово 6", "слово 7", "слово 8");
$words_add = array();
for ($i = 0; $i < $steps; $i++) {
$words_add[] = $words_list[rand(0, count($words_list)-1)];
}
$f = fopen("words", "a+");
fwrite($f, implode("<br>", $words_add) . "<br>");
fclose($f);
file_put_contents("last_time", $current_time);
}
echo @file_get_contents("words");
?>
<script>
setTimeout(function () {document.location.reload(); }, 3000);
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question