我在學習PHP和Drupal。我需要引用一個名爲$ contexts的數組中包含的變量。如何引用這個變量(嵌套的對象/數組)?
所以print_r($contexts)
給了我這樣的:
Array (
[context_view_1] => ctools_context Object (
[type] => view
[view] => view Object (
[db_table] => views_view
[result] => Array (
[0] => stdClass Object (
[nid] => 28
[node_data_field_display_field_display_value] => slideshow
)
)
伊克混淆。我想使用node_data_field_display_field_display_value變量。我認爲我的代碼需要像這樣,但我知道這是不正確的:
if ($contexts['context_view_1']['view']['result'][0]
['node_data_field_display_field_display_value'] == 'slideshow') then do whatever...
謝謝!
嘗試了這一點:'$環境[ 'context_view_1'] - >查看 - >結果[0] - > node_data_field_display_field_display_value ' – JohnP 2011-03-09 17:08:10