I’m doing a script that involves choosing a random string from an array and redirecting to it (using headers). I want it so that using a get variable and it will load the array with the same name as it. So, if the get variable is random, then it would load the array random and use that.
Does that make sense?
I’m using for a random avatar script, so that it will get a username then choose the array for that username, then select a random avatar URL.
PHP supports “variable variables”, so you could do something like:
So, if you had an array defined in your script:
and the value of
$_GET['username']is'bill', then$billwould be copied to$arrby the above.For more see this documentation