Here is the result of print_r($object):
Array
(
[0] => stdClass Object
(
[title] => Test procedures in watermelons
[nid] => 494
[type] => chsmanuscript
)
[1] => stdClass Object
(
[title] => How to eat cookies
[nid] => 520
[type] => chsmanuscript
)
)
How can I manually add a 3rd object item in this object array? I have tried the below but it does not work:
$object[2]->title = 'test';
$object[2]->nid = '999';
$object[2]->type = 'chsmanuscript'
The error is:
Fatal error: Cannot use object of type DatabaseStatementBase as array
You must first create a new
stdClassobject in the specific array element before you try to access it’s members: