0
for ($count = 1; $count <= 5; ++$count) {
$test = ${'node->field_aw_score_' . $count}[LANGUAGE_NONE][0]['value'];
echo $test;
}
拋出錯誤:引用一個動態變量?
Notice: Undefined variable: node->field_aw_score_1
Notice: Undefined variable: node->field_aw_score_2
Notice: Undefined variable: node->field_aw_score_3
Notice: Undefined variable: node->field_aw_score_4
Notice: Undefined variable: node->field_aw_score_5
然而,變數確實存在。我想引用:
$node->field_aw_score_1[LANGUAGE_NONE][0]['value']
然後
$node->field_aw_score_2[LANGUAGE_NONE][0]['value']
等動態變量。我究竟做錯了什麼?謝謝。
使用'$計數++',而不是'$ ++ count' – Bora
'$節點 - > { 'field_aw_score_'。 $ count} [LANGUAGE_NONE] [0] ['value']' –
@ hek2mgl我以前沒見過這樣,thx – Bora