我使用codeigniter。我拿到所有商标。我想检查每一个我的平均成绩是否等于或等于F。我想检查每个数组gpa = f / F使用in_array
或其他函数,我不使用foreach
for
Array
(
[0] => stdClass Object
(
[id] => 5889
[name] => Dom
[student_id] => 2018000004
[roll] => 1
[class] => 6
[department] =>
[subject_type] => 0
[subject_name] => 24
[exam_type] => 1
[exam_year] => 2018
[full_mark] => 100
[getmark] => 55
[gpa] => F
[log] => 2018-11-06 20:32:33
)
[1] => stdClass Object
(
[id] => 5890
[name] => Rohim
[student_id] => 2018000006
[roll] => 1
[class] => 6
[department] =>
[subject_type] => 0
[subject_name] => 24
[exam_type] => 1
[exam_year] => 2018
[full_mark] => 100
[getmark] => 60
[gpa] => 4
[log] => 2018-11-05 19:42:26
)
)
我要检查。没有任何循环。
if(in_array('F',$resultList)){
echo "match";
}else {
echo "not match";
}
答案 0 :(得分:0)
如果只需要知道数组中是否有F
,则可以将array_column()
与in_array()
一起使用。
//Create an array of GPA's
$arr_gpa = array_column($array, 'gpa');
if(in_array('F', $arr_gpa)) {
echo "match";
} else {
echo "not match";
}