Working Code:
$node1 = new stdClass();
$node1->field_granule_comments1['und'][0]['value'] = "test";
print_r($node1);
Result
stdClass Object
(
[field_x] => Array
(
[und] => Array
(
[0] => Array
(
[value] => test
)
)
)
)
I need output like this but I have value in a variable. For example:
$id="field_x['und'][0]['value']";
$node2 = new stdClass();
$node2->$id ="test";
print_r($node2);
Output of this code is :
stdClass Object
(
[field_x['und'][0]['value']] => test
)
How can I come up with output similar to "Working Result", taking the value from the variable ?