$arr = Array
(
Array(
"id" => "1",
"player_name" => "Jack",
"type" => "Arcades",
"high_score"=> "10000",
"score"=> "500",
),
Array(
"id" => "1",
"player_name" => "Jack",
"type" => "Racing",
"high_score"=> "12000",
"score"=> "700",
),
Array(
"id" => "2",
"player_name" => "Steve",
"type" => "Racing",
"high_score"=> "10000",
"score"=> "400",
),
Array(
"id" => "2",
"player_name" => "Steve",
"type" => "Arcades",
"high_score"=> "12000",
"score"=> "600",
),
Array(
"id" => "2",
"player_name" => "Steve",
"type" => "Casual",
"high_score"=> "14000",
"score"=> "650",
),
Array(
"id" => "2",
"player_name" => "Steve",
"type" => "Strategy",
"high_score"=> "10000",
"score"=> "500",
),
);
預期輸出:PHP組多維數組?
$arr = Array (
'1'=>
Array(
"id" => "1",
"player_name" => "Jack",
"type" => "Arcades,Racing",
"high_score"=> "12000",
"score"=> "1200",
),
'2'=>
Array(
"id" => "2",
"player_name" => "Steve",
"type" => "Racing,Arcades,Casual,Strategy",
"high_score"=> "14000",
"score"=> "2150",
),
);
我混淆有關如何使用多維到組陣列按預期輸出。我的高級建議我使用多維數組,因爲我嘗試了很多次,但我不知道如何分組數組,請問有人能幫助我!
@nice ...但是這會給high_score爲10000 ID 2是14000,但整體的短期和快速:) +1簡短的回答 – user1234
高分也可以用一個條件每次迭代 – Shahrukh
感謝檢查求助! –