0
我有子陣列的陣列以下列格式組切片由子陣列值Golang
Array
(
[0] => Array
(
[unit_id] => 6504
[assignment_name] => Grade assignment
[assignment_description] =>
[assignment_total_score] => 10
[unit_type_name] => Homework
[is_graded] => 1
[standard_id] => 1219
[scoring_type] => score
[attempt_score] => 8
[unit_duedate] => 2016-02-10 09:00:00
[standard] => Array
(
[0] => stdClass Object
(
[unit_id] => 6504
[is_formal] => 1
[assignment_name] => Grade assignment
[assignment_description] =>
[standard_id] => 1220
[standard_name] => 9-10.RL.3
[standard_description] => Analyze how complex characters (e.g., those with multiple or conflicting motivations) develop over the course of a
)
)
)
[1] => Array
(
[unit_id] => 8584
[assignment_name] => Sine and Cosecant Graphs
[assignment_description] => Define the sine and cosecant graphs using a unit circle
[assignment_total_score] => 15
[unit_type_name] => Paper
[scoring_type] => score
[attempt_score] => 0
[unit_duedate] => 2016-04-29 09:00:00
[standard] => Array
(
[0] => stdClass Object
(
[unit_id] => 8584
[is_formal] => 1
[assignment_name] => Sine and Cosecant Graphs
[assignment_description] => Define the sine and cosecant graphs using a unit circle
[assignment_total_score] => 15
[standard_id] => 82790
[standard_name] => 9-10.RL.7
)
)
[2] => Array
(
[unit_id] => 11611
[assignment_name] => Adding 5 + 3 + 6
[assignment_description] =>
[assignment_total_score] => 10
[unit_type_name] => Homework
[standard_id] => 82772
[scoring_type] => score
[attempt_score] => 0
[unit_duedate] => 2016-08-23 19:00:00
[standard] => Array
(
[0] => stdClass Object
(
[unit_id] => 11611
[is_formal] => 1
[assignment_name] => Adding 5 + 3 + 6
[assignment_description] =>
[assignment_total_score] => 10
[standard_id] => 82772
[standard_name] => 9-10.RL.1
)
)
)
)
我想基於在每個子陣列的unit_type_name
字段它組成一個新的切片。
如何將切片按unit_type_name
分組?有沒有任何原生GO功能可以做到這一點? 如果我爲循環上面那麼我會得到一個重複的,我怎麼能避免這一點?
我是正確的,這是一個PHP數組? –
是的,這是PHP的數組,但同樣的數據是使用去朗讀....如何根據unit_type_name進行分組? – Ali
你是什麼意思的「組片」?你想分類嗎?你想把它們放在新的切片中嗎?你有什麼嘗試,沒有奏效? – JimB