我正在尝试在foreach循环中仅输出一次内容。目前,当用户填写表单时,由于foreach的缘故,每个被跳过的记录都会显示消息。如果有35条被跳过的记录,我将会收到35条消息。我想避免这种情况,并能够在整个结果页面上仅显示一个echo。如何做到这一点呢?我想我可能需要在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;
}
}
}
}
if($course->aircraft == '1')
。我已经更新了主要信息以向您展示我的意思。 - user2442178