2013-07-11 223 views
0
Array (
    [und] => Array (
     [0] => Array (
      [tid] => 37 
      [taxonomy_term] => stdClass Object (
       [tid] => 37 
       [vid] => 9 
       [name] => $10 - $20 
       **[description] => $10 - $20** 
       [format] => filtered_html 
       [weight] => 1 
       [vocabulary_machine_name] => prices 
      ) 
     ) 
    ) 
) 

一直在尝试这样的事情:如何访问此嵌套数组中的对象属性?

print $node->field_price['und']['0']['tid']->taxonomy_term; 

这就像在有对象的嵌套数组too..I'm真的不知道如何让[说明]属性,这似乎是内在那里的对象。

任何帮助?请!

回答

1

尝试:

echo $node->field_price['und'][0]['taxonomy_term']->description; 
+0

致命错误:无法使用stdClass类型的对象作为第24行中的C:\ xampp \ htdocs \ drupal \ sites \ all \ themes \ simple7 \ node.tpl.php中的数组 – user12024

+0

您确定您提供的问题是'var_dump($ node);'?的输出 –

+0

其输出为 – user12024

0

试试这个:

print $node->field_price[LANGUAGE_NONE]['0']['taxonomy_term']->description; 

LANGUAGE_NONE是常数,对于不确定的语言具有 '关键' 的名称和整个Drupal的使用。