我一直在試圖解決這個問題,但我一直在獲取「獲得」作爲輸出,而不是用戶。多維數組,我該如何解決這個問題?
array(2)
{
["SKILL"]=> array(2)
{
[0]=> array(2)
{
["user"]=> string(7) "USERNAME" ["gained"]=> int(15)
}
[1]=> array(2)
{
["user"]=> string(6) "USERNAME" ["gained"]=> int(8)
}
[2]=> array(2)
{
["user"]=> string(6) "USERNAME" ["gained"]=> int(3)
}
["SKILL2"]=> array(2)
{
[0]=> array(2)
{
["user"]=> string(7) "USERNAME" ["gained"]=> int(10)
}
[1]=> array(2)
{
["user"]=> string(6) "USERNAME" ["gained"]=> int(7)
}
[2]=> array(2)
{
["user"]=> string(6) "USERNAME" ["gained"]=> int(5)
}
}
我希望它輸出:
USERNAME ranked 1 gained 15<br/>
USERNAME ranked 2 gained 8<br/>
USERNAME ranked 3 gained 3<br/>
<br/><br/>
["SKILL2"]:<br/>
USERNAME ranked 1 gained 10<br/>
USERNAME ranked 2 gained 7<br/>
USERNAME ranked 3 gained 5<br/>
<br/><br/>
該陣列由 「獲得」 排序。
用戶排名$ loopRuns上漲$獲得
foreach($ar1 as $skill => $value)
{
$i = 0;
echo "<b>Skill: $skill</b><br/>";
foreach($value as $ar2 => $ar3)
{
foreach($ar3 as $key => $value)
{
$i++;
echo "$key Ranked #$i gained $value<br/>";
}
}
echo "<br/>";
}
能否請您發佈'var_export(AR1 $)的輸出;'而不是print_r的結果呢?讓它更容易測試... – VolkerK 2013-05-13 08:10:50