Random numbers within a range in PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /******************************************************* * MYCPLUS Sample Code - https://www.mycplus.com * * * * This code is made available as a service to our * * visitors and is provided strictly for the * * purpose of illustration. * * * * Please direct all inquiries to saqib at mycplus.com * *******************************************************/ <html> <head> <title>rand</title> </head> <body> <? srand(time()); //get ten random numbers from -100 to 100 for($index = 0; $index < 10; $index++) { print(rand(-100, 100) . "<br />\n"); } ?> </body> </html> |