Simple question here... I was wondering if it's possible to access class propertys by it's name in any way.
Imagine this scenario:
$array = array(
'foo' => 'bar',
'hello' => 'world',
'chuck' => 'norris'
);
And then have this class:
class MegaClass {
public $foo, $hello, $chuck;
}
I was wondering if I could set MegaClass::foo
to bar
, MegaClass::hello
to world
and so on, automatically. So, given the array, and given the object, the object is filled. This could be really handy when retreiving data from a form with properties filled...