M
在数组中我有学生及其技能和获得的分数
if x ? 'M' : 'L' return
我想根据数组1过滤学生
我想要学生
Array
(
[3] => 2 // skill => eligible marks
[63] => 6
[128] => 3
)
如果标准分层返回学生ID
答案 0 :(得分:1)
使用以下方法:
$marks = array
(
3 => 2, // skill => eligible marks
63 => 6,
128 => 3
);
// $arr is your initial array of student data
$student_ids = [];
$marks_count = count($marks);
foreach ($arr as $k => $items) {
// if number of marks coincide
if (count($marks) != count($items)) continue;
foreach ($items as $item) {
if (!isset($marks[$item['skill_id']])
|| $marks[$item['skill_id']] >= $item['gd_score']) {
continue 2;
}
}
$student_ids[] = $k;
}
print_r($student_ids);
输出:
Array
(
[0] => 24
)