Adding to a class' variables with elements in an object

fahad000

New Member
\[code\]$class = new Class;$foo = json_decode($_POST['array']);\[/code\]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\[code\]$foo\[/code\]. How do I move the elements in \[code\]$foo\[/code\] over to \[code\]$class\[/code\], so that:\[code\]$foo->name\[/code\] becomes \[code\]$class->name\[/code\]?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.
 
Back
Top