I am working on a function that takes a string as an argument, which I need to use to get the value of a variable of the same name.
For example
If the string $foo = "$_POST['email']";
is passed I need to retrieve the value of $_POST['email']
and store it as $example
, so that $_POST['email'] == $example
would return true. There is no feasable way of passing the value directly to function (the variable has to be dynamic to make the function worthwhile).
I did think of using variable variables but they don't work with super globals which will be the primary source of the values I need.
Basically is there a way to get the value of a variable (usually in a superglobal array) with the needed variable as a string?
Let me know if more detail is needed.
Thanks