Hello everyone!
This is a pretty basic question, but when calling for a random number in php with rand(x,y), can one substitute x and y for variables, and if so, how would one do it?
Thanks!
Rand variables
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Rand variables
You can't do it with the basic function, no. But how most developers do something like that is with an array. You fill up the array with whatever variable values you want, and then use the randomly generated number as the index on the array, thus pulling a random value out of it.
The indelible lord of tl;dr
Re: Rand variables
ohhh okay that makes sense, thanks a lot!
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny