assign random values to variables

how can i assign the random values generated from the rand() function to different variables for later use. so if a user inputs a value of 10, i want 10 random numbers (no limits) to be generated and then stored under different variables for later use. i’m new at this

There has to be limits for rand to work, but the max can be really high. As for the problem, use arrays. use the user input number (in this case, 10) as the max in a for loop.
[php]$rand = array();
for($i = 0; $i < $user_max; $i++) {
$rand[] = rand(0, 999);
}[/php]From that, you’ll have an array containing 10 random numbers.

You could use what are called “variable variables” but… how would you code for random variables? You would have to use an array like richei mentioned.

Sponsor our Newsletter | Privacy Policy | Terms of Service