vendredi 13 février 2015

PHP Rand but dont allow specific numbers above or below

Good day,


Iam trying to use the PHP Rand function, works great but I want to specify it more. Current code that works:



$min=100;
$max=500;
$random=rand($min,$max);
echo $random;


What I want it todo is that each number generated must be at least +10 or -10. For example it generates the following:



  • 110 (1st generated)

  • 116 (No)

  • 101 (No)

  • 90 (Yes)

  • 100 (No)

  • 120 (Yes)

  • 103 (No)


And so forth


Does rand allow itself to be manipulated?


Aucun commentaire:

Enregistrer un commentaire