Search code examples
phprandomwords

Display Certain Words After certain time interval


I want to display these two words "current streams" and "top streams" using "php" after an interval of 30 seconds.

they must not to be random.. but like this:

  • For the first 30 seconds the phrase "current streams" is displayed,
  • In the next 30 seconds, the phrase "top streams" is displayed,
  • (repeating)

I tried srand(floor(time() / (30))); but it display them randomly some time same word 2 times..!! Page Refreshing is allowed..!! Do not want to use javascript


Solution

  • If you are looking for in-page changes (so no refresh) then you need to use JavaScript.

    In reponse to your question: Why not get the current time (seconds) and see if it's greater than 00 and smaller than 30 echo string a, else echo string b:

    $datCurrentTime = date("s");
    if ($datCurrentTime >= '00' && $datCurrentTime < '30') {
       echo "Current streams";
    } else {
       echo "Top streams";
    }