$class = new Class;
$foo = json_decode($_POST['array']);
In this highly contrived example, I have a class with its own functions and variables, blah blah.
I also just decoded a JSON string, so those values are now in$foo
. How do I move the elements in $foo
over to $class
, so that:
$foo->name
becomes $class->name
?
Would be trivial if I knew what all the elements were, yes... except for the sake of being dynamic, let's say I want them all transferred over, and I don't know their names.