Any random number between 0 to 100 can be generated like this:
<?php
$min = 0;
$max = 100;
$random = rand($min,$max);
?>
Now I can place this $random anywhere in my file to generate a random number. But the problem is when I place this on more than one place all those places have same value (if one random number is 17 all will be 17).
I am doing something like this to do that in more than one place:
$random2 = rand($min,$max);
$random3 = rand($min,$max);
$random4 = rand($min,$max);
$random5 = rand($min,$max);
And placing those in all locations.
Doing so takes more of my space in my script. Is there any better way to do what I want?
Why not making a function?:
that way you have to call only the function.