2013-07-11 123 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的使用。