a silly question.... how to retrieve a value from a nest stdClass Object?

Here is part of the output from print_r($data):

stdClass Object
(
[node_title] => admin -reports - general - article -file
[nid] => 57
[node_created] => 1302612250
[field_data_field_file_node_entity_type] => node
[_field_data] => Array
(
[nid] => Array
(
[entity_type] => node
[entity] => stdClass Object
(
[vid] => 57
[uid] => 1
[title] => admin -reports - general - article -file
[log] =>
[status] => 1
[comment] => 2
[promote] => 1
[sticky] => 0
[nid] => 57
[type] => file
[language] => und
[created] => 1302612250
[changed] => 1302612250
[tnid] => 0
[translate] => 0
[revision_timestamp] => 1302612250
[revision_uid] => 1
[body] => Array
(
[und] => Array
(
[0] => Array
(
[value] => On February 23, 2011 the Mines and Forestry,

[summary] =>
[format] => filtered_html
[safe_value] =>

On February 23, 2011 the Mines and Forestry,

[safe_summary] =>
)

)

)

[field_attac] => Array
(
[und] => Array
(
[0] => Array
(
[fid] => 7
[display] => 1
[description] =>
..........................

I want to get the value from [fid]=>7, what should I do?
I can get the [entity_type] value (node) using this:
print $data->_field_data->nid->entity_type, but I wasn't sucessful in getting the value from next stdClass object.
What syntax should I use?

Comments

casey’s picture

Category: task » support

print $data->_field_data['nid']['entity_type'];

next object?

sadashiv’s picture

Component: Miscellaneous » Code

Yes for getting the type you can make use of

print $data->_field_data['nid']['entity_type'];

and to get the fid you can make use of

print $data->_field_data['nid']['entity']->field_attac['und'][0]['fid'];

Liam Morland’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.