0
배열 내부에있는 값을 필터링하려고합니다. 이를 위해 다음 구문을 사용했습니다.배열 내부에 예기치 않은 'if'가 있습니다. Laravel
$selected = array(
if ($request->annual!=0) {
'annual' => $request->annual,
}
if ($request->registration!=0) {
'registration' => $request->registration,
}
if ($request->monthly!=0) {
'monthly' => $request->registration,
}
if ($request->exam!=0) {
'exam' => $request->exam,
}
if ($request->laboratory!=0) {
'laboratory' => $request->laboratory,
}
if ($request->computer_lab!=0) {
'computer_lab' => $request->computer_lab,
}
);
구문 오류가 발생합니다.
syntax error, unexpected 'if' (T_IF), expecting ')'
여기서 어떤 문제가 발생합니까? 누구든지 나를 도울 수 있습니까?