foreach
この配列をループ内で実行し、同じを共有する行をグループ化するにはどうすればよいsection_id
ですか?
すべての行とセクションにコメント ブロックのラベルを付けました。
これが配列です
Array (
[0] => Array ( // Row 1
[assessment_selection_id] => 63
[assessment_id] => 32
[section_id] => 1 // Section 1
[question_id] => 1
[selection] => 2
[timestamp] => 1368160586
)
[1] => Array ( // Row 2
[assessment_selection_id] => 61
[assessment_id] => 32
[section_id] => 2 // Section 2
[question_id] => 1
[selection] => 3
[timestamp] => 1368160510
)
[2] => Array ( // Row 3
[assessment_selection_id] => 61
[assessment_id] => 32
[section_id] => 2 // Section 2
[question_id] => 1
[selection] => 3
[timestamp] => 1368160510
)
[3] => Array ( // Row 4
[assessment_selection_id] => 61
[assessment_id] => 32
[section_id] => 2 // Section 2
[question_id] => 1
[selection] => 3
[timestamp] => 1368160510
)
)
期待される結果
Array (
[0] => Array ( // Section 1
[0] => Array ( // Row 1
[assessment_selection_id] => 63
[assessment_id] => 32
[section_id] => 1
[question_id] => 1
[selection] => 2
[timestamp] => 1368160586
)
)
[1] => Array ( // Section 2
[0] => Array ( // Row 1
[assessment_selection_id] => 61
[assessment_id] => 32
[section_id] => 2
[question_id] => 1
[selection] => 2
[timestamp] => 1368160586
)
[1] => Array ( // Row 2
[assessment_selection_id] => 61
[assessment_id] => 32
[section_id] => 2
[question_id] => 1
[selection] => 2
[timestamp] => 1368160586
)
[2] => Array ( // Row 3
[assessment_selection_id] => 61
[assessment_id] => 32
[section_id] => 2
[question_id] => 1
[selection] => 2
[timestamp] => 1368160586
)
)
)
配列なしの期待される結果
セクション 1
行 1
assessment_selection_id, assessment_id, section_id, question_id, selection, タイムスタンプ
第2節
行 1
assessment_selection_id, assessment_id, section_id, question_id, selection, タイムスタンプ
行 2
assessment_selection_id, assessment_id, section_id, question_id, selection, タイムスタンプ
行 3
assessment_selection_id, assessment_id, section_id, question_id, selection, タイムスタンプ