我试图在 foreach 中回显内容一次。目前,当用户填写表单时,会针对跳过的每条记录显示该消息。如果跳过了 35 条记录,我将收到 35 条消息,因为 foreach。我想避免这种情况,并且能够为整个结果页面只显示一个回显。我怎样才能做到这一点?我想我可能必须在 foreach 之外执行此操作,但我不知道如何将它从 foreach 中取出。
foreach($allcourses as $course)
{
if(Auth::LoggedIn())
{
if(Auth::$userinfo->rank == 'Student')
{
if($course->aircraft == '1')
{
echo '<div class="msg-red">Some lessons could not be found, because you may not be entitled to view/book them at this stage of your course.</div><br/>';
continue;
}
if($course->aircraft == '2')
{
echo '<div class="msg-red">Some lessons could not be found, because you may not be entitled to view/book them at this stage of your course.</div><br/>';
continue;
}
}
}
}