How to create variable names dynamically
Posted: Fri Jul 21, 2006 10:23 pm
If this is possible I would like to know how to do it..
So if a variable named thisName is posted, I can then access that variable with
Maybe that code I wrote up there will work but I'm assuming it's not that easy..
Code: Select all
class sample
{
function __construct()
{
$this->transferPost();
}
function transferPost()
{
foreach ($_POST as $key => $value)
{
$this->$key = $value; // <--
}
}
}Code: Select all
$howdy = $sample->thisName;