0

我有一个来自drupal的这样的数组输出,我如何从field_episode_tags访问[name]的值,到目前为止我有这个

print $node->field_episode_tags['und']['0']['taxonomy_term']->['name']

当我开始使用“分类术语”时,我尝试使用另一个对象-> poitner,但这没有用。

stdClass Object
    (
        [vid] => 25
        [uid] => 1
        [title] => Is there any cosmos theory?
        [log] => 
        [status] => 1
        [comment] => 1
        [promote] => 0
        [sticky] => 0
        [nid] => 25
        [type] => tv_episode
        [language] => en
        [created] => 1380610491
        [changed] => 1381115053
        [tnid] => 0
        [translate] => 0
        [revision_timestamp] => 1381115053
        [revision_uid] => 1
        [body] => Array
            (
                [und] => Array
                    (
                        [0] => Array
                            (
                                [value] => summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text 
                                [summary] => 
                                [format] => filtered_html
                                [safe_value] => <p>summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text</p>

                                [safe_summary] => 
                            )

                    )

            )

        [field_video_category] => Array
            (
                [und] => Array
                    (
                        [0] => Array
                            (
                                [tid] => 25
                            )

                    )

            )

        [field_featured] => Array
            (
            )

        [field_kaltura_video] => Array
            (
            ) und 0 taxonomy term->name

        [field_episode_tags] => Array
            (
                [und] => Array
                    (
                        [0] => Array
                            (
                                [tid] => 95
                                [taxonomy_term] => stdClass Object
                                    (
                                        [tid] => 95
                                        [vid] => 1
                                        [name] => zen
                                        [description] => 
                                        [format] => 
                                        [weight] => 0
                                        [vocabulary_machine_name] => tags


                       [rdf_mapping] => Array
4

1 回答 1

1

您需要不带括号 [] 直接访问实例数据成员。这些用于数组键。

 print $node->field_episode_tags[LANGUAGE_NONE]['0']['taxonomy_term']->name
于 2013-10-07T09:05:06.560 回答