0
我正在做一個配置文件測驗。這只是代碼的一個例子。最終我會爲所有可能的組合做一個循環。基本上,如果學生選擇問題1的回答3(什麼是你的身高 - 小,中,大,xl,xxl),我希望他們的pgheight存儲爲4,sgheight爲9,cheight爲4等。最終數組將包含16 $ pos和16 $ attr,每個組合有5個分數。希望這是有道理的。謝謝你的幫助。 例如結合數組獲得第三個數組值
function height(){
$pos=array("pg","sg","c");
$attr=array("height","weight","strength");
$pgheight=array(1,2,3,4,5);
$sgheight=array(6,7,8,9,10);
$cheight=array(1,2,3,4,5);
$ans=3;
$i=0;
// THIS IS THE CODE THAT DOESN'T SEEM TO WORK.
// My logic is $pgheight=$pgheight[3];
$pos[$i].$attr[$i]=$pos[$i].$attr[$i]."[".$ans."]";
echo $pgheight;
}
太棒了。非常感謝克里斯! – matt