如何正确分组数组:(最终结果)
Array
(
[0] => Array
(
[Player] => CaLvErT
[0] => Array
(
[SnapTime] => 1330028992
[PlayCount] => 9
)
)
[1] => Array
(
[Player] => CaLvErT
[0] => Array
(
[SnapTime] => 1330202828
[PlayCount] => 8
)
)
)
我的 mySQL/PHP 符合我的尝试:
$iTestGrid = array();
$ChartSQL = "SELECT player,snap,count(*) AS pCnt";
$ChartSQL .= " FROM sc".$DBSvr;
$ChartSQL .= " WHERE hex(alliance) IN (hex('Twitch'))";
$ChartSQL .= " GROUP BY player,snap";
$ChartSQL .= " ORDER BY player ASC,snap ASC";
$FinalResult = $db-> query($ChartSQL);
while ($FinalRow = $db-> fetch_assoc($FinalResult)){
$iTestGrid[] = array(
'Player' => $FinalRow['player'],
array(
'SnapTime' => (int)$FinalRow['snap'],
'PlayCount' => (int)$FinalRow['pCnt']
)
);
}
基本上想知道如何对同名的玩家进行分组。
在此先感谢您的帮助!(请原谅我,因为我并不热衷于完全理解数组是如何工作的,整天/晚上都在书店里,但仍然得到它的一部分,而不是很多)