데이터베이스에서 Student_id는 0 값을 포함합니다. 조건이 맞는지 확인하고 싶지만 필요한 결과가 나오지 않습니다. 나는 경우 조건에 다음과 같은 시나리오를 시도 :제로 정수와 값을 비교하는 방법
if(is_null($item['student_id'])) {}
if($item['student_id'] === 0){}
if($item['student_id'] == 0){}
if(intval($item['student_id']) == 0){}
if(strval("$item['student_id']") == "0"){}
참고 : 현재 스피 조건의 경우에 어떤 메시지를 인쇄하려고합니다. 그러나 student_id = 0이면 아무 것도 인쇄되지 않습니다. student_id가 0이 아니면 인쇄가 정상적으로 작동합니다.
나는 어떤 일을 잘못하고 어떻게 교정 할 수 있습니까?
내가 위해서 var_dump를 추가 한
array
'_id' =>
object(MongoId)[2]
public '$id' => string '50906d7fa3c412bb040eb577' (length=24)
'student_id' => int 0
'type' => string 'exam' (length=4)
'score' => float 54.653543636265
array
'_id' =>
object(MongoId)[6]
public '$id' => string '50906d7fa3c412bb040eb578' (length=24)
'student_id' => int 0
'type' => string 'quiz' (length=4)
'score' => float 31.950044967421
array
'_id' =>
object(MongoId)[2]
public '$id' => string '50906d7fa3c412bb040eb579' (length=24)
'student_id' => int 0
'type' => string 'homework' (length=8)
'score' => float 14.850457681164
경우 ($ 항목 [ ' student_id ']> 0) {} – GBD
'$ item ['student_id ']'안에 값이 있습니까? 그렇다면 그 가치는 무엇입니까? –
fyi : 마지막 버전은 큰 따옴표로 묶인 문자열 내의 배열에서 인용 된 키를 사용하는 것에 대한 경고를 발행합니다. –