2 回答
TA贡献1860条经验 获得超8个赞
您可以使用只break执行最后foreach一次,这样可以避免同一用户的下一条记录
foreach($usrwcert as $user){
$userdet = $DB->get_record('user', array('id' => $user->userid), $fields = '*');
$mform->addElement('html', '<option value="'.$userdet->id.'">'.$userdet->firstname.' '.$userdet->lastname.' ('.$userdet->username.', '.$userdet->email.')</option>');
break;
}
TA贡献1862条经验 获得超6个赞
this works
$unica=array();
foreach($usrwcert as $user){
if(!in_array($user->userid,$unica)){
$userdet = $DB->get_record('user', array('id' => $user->userid), $fields = '*');
$mform->addElement('html', '<option value="' . $userdet->id . '">' . $userdet->firstname . ' ' . $userdet->lastname . ' (' . $userdet->username . ', ' . $userdet->email . ')</option>');
}
$unica[]=$user->userid;
}
- 2 回答
- 0 关注
- 143 浏览
添加回答
举报