I am trying to access a field value in an array (cstom formatter module) .Although I found many exemples on the net i am not able to access and print the follwing value:

print $node->field_youtube_video['und'][0]['video_id'];

the array is :

Array
(
[#obj_type] => node [#object] => stdClass Object
(
[vid] => 375 [uid] => 1 [title] => Test [log] => [status] => 1 [comment] => 0 [promote] => 0 [sticky] => 0 [ds_switch] => [nid] => 40 [type] => page [language] => und [created] => 1401114206 [changed] => 1401266810 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1401266810 [revision_uid] => 1 [body] => Array
(
[und] => Array
(
[0] => Array
(
[value] =>

Überall dieselbe alte Leier.

[safe_summary] => ) ) )

[field_youtube_video] => Array
(
[und] => Array
(
[0] => Array
(
[input] => https://www.youtube.com/watch?v=AwTd08P4E3k [video_id] => AwTd08P4E3k ) ) )

Why is this not working?

thanx for any input on this, it drives me mad....

Comments

cybernomad’s picture

the right answer was :

print $variables['#object']->field_youtube_video['und'][0]['video_id'];

after I discovered this interesting article I was able to solve it myself

http://alligatorsneeze.com/working-arrays-and-objects-drupal-printr-and-dpm