'How can I make a counter from 1 to 100 with PHP? [closed]

Hello friends, how can I add a counter that will count from 1 to 100 and then count from 1 to 100 again after a few minutes? It will be with PHP.



Solution 1:[1]

Here is a way to count until 100 in PHP but please make sure you choose your tags right, your question is currently marked as a javascript question

I know it is related to javascript but your problem doesn't include even a piece of javascript

<?php
while (1){ 
    for ($x = 0; $x <= 100; $x++) {
        echo "The number is: $x <br>";
        sleep(1);
    }
}
?>

Solution 2:[2]

I would strongly suggest CRON JOBS for periodic script execution.

But it looks like some school or maybe even for fun task. So the Answer from @Ramsey above should be sufficient.

(dont forget to kill the infinite process created by while (1))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ramsey
Solution 2 Fappie.