mardi 27 mars 2018

Continuous random number generator adding numbers to max - PHP

I have a random number generator that spits out a number between 1 and 5. This thing does so every five minutes using a simple script "random.php".

<?php
header("Refresh:1");
$num = rand(1,5);

What I want to do is to have another script look at this one, retrieve the $num number and drop that to a $total, and keep doing to until that total reaches 20. Adding up the numbers is not an issue, the problem is to keep getting the new random numbers? What I want to do is along the lines of this but I cannot figure out how:

<?php
require("random.php");

$max = 20;
$now = 0;

while ($now <= $max){
    $new = [get new randon number somehow] 
    $now = $now + $new;
    echo "$now<br>";
}

I want to solve this in PHP if possible, not interested in JS or CURL solutions at the moment. I need to exhaust this in PHP.




Aucun commentaire:

Enregistrer un commentaire