Array
(
[0] => Array
(
[0] => Array
(
[sem] => s2
[year] => 3
[subjectcode] => web
[subjectname] => webtechnology
[internal] => 30
[external] => 65
[credits] => 3
)
)
[1] => Array
(
[0] => Array
(
[sem] => s2
[year] => 3
[subjectcode] => js654
[subjectname] => java
[internal] => 25
[external] => 60
[credits] => 3
)
)
)
答案 0 :(得分:0)
[the second, ::slotted(*) rule]
首先创建一个$result = array();
foreach ($array as $array2) {
foreach ($array2 as $values) {
$result[$values['year']][$values['sem']][] = $values;
}
}
数组以将结果存储在其中。然后遍历两个嵌套数组以使用$result
和$values
值到达最里面的year
数组
当将sem
数组添加到year
数组时,每个sem
数组的$values
和$values
值都将用作键。这将按年份然后按学期对值进行排序。
结果:
$result