I know you can create an array like this:
$a = array();
and add new name value pairs to it, for example:
$a['test'] = 'my new value';
You can even omit the first line, although bad practice!
I find objects easier to read and understand, so I made an array of name arrays and passed it to the object:
$a = (object)$a;
This way I can access the options:
$a->test;
It seems wasteful for the extra cost of creating an Array to start with, is it possible to just create an object, and then somehow just add name value pairs to it the same way I would do an array?
thank
source
share