我一直在尝试解决这个问题,但我一直“获得”作为输出而不是用户。
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/>
数组按“ gain ”排序。
用户排名$loopRuns获得$ gained
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/>";
}