Small problem with array objects. Print_r ($ GLOBALS [$ class]); the output result is as follows: ot_cod_feeObject (& nbsp; [title] & gt; cash payment service fee & nbsp; [output] & gt; array & nbsp; (& nbsp;) & nbsp; [code] & gt; small problem with Array object.
Print_r ($ GLOBALS [$ class]);
The output result is as follows:
Ot_cod_jsonobject
(
[Title] => cash payment service fee
[Output] => Array
(
)
[Code] => ot_cod_fee
)
Ot_total Object
(
[Title] => Total
[Output] => Array
(
)
[Code] => ot_total
)
I want to add a new entry in this array object. how can I write it?
$ GLOBALS ['test'] = array ('title' => 'logistic', 'output' => array (), 'code' => 'ot _ logistics ');
In this way, the array is added, and how to add the image.
------ Solution --------------------
Discussion
$ Arr = (object) array ('title' => 'logistic', 'output' => array (), 'code' => 'ot _ logistics ');
How do I customize the object name?
------ Solution --------------------
PHP code
Class object_name {} $ p = new object_name; $ ar = array ('title' => 'logistic', 'output' => array (), 'code' => 'ot _ logistics ', 'description' => 'logistic', 'sort _ order' => 888 ); foreach ($ ar as $ k = >$ v) $ p-> $ k = $ v; print_r ($ p );