Image

Imagedevolve_absolve wrote in Imagephp

More on the ill-fated dice roller

OK, so far I've had a million and one pointers, and each time I keep getting closer to the result so big thumbs up.

I've realised though that what I probably need is an array to store each result in using this code:

function droller($name,$action,$dice) {
$i=0;
while ($i < $dice) {
srand((double)microtime()*1000000);
$randval = rand(1, 10);
return "$name rolls $dice for $action: $randval, ";
$i++;
}
}


$res = droller(cameron, test, 5);
echo "$res";


Would this be an accurate statement? Currently it will only return the last processed $randval calculated, so storing each result in an array that is $dice lon would solve this I think.

Comments?