echo 'SSH Timeout: <select name="ssh_timeout"';
$time = array('1', '5', '15', '30', '60');
foreach ($time as $value) {
if (15 == $value) {
echo "<option value='$value' selected>$value seconds</option>";
}
else {
echo "<option value='$value'>$value seconds</option>";
}
}
echo '</select>';
该代码未显示1
的第一个值,而是从5
开始到60
。我该如何解决?
答案 0 :(得分:1)
您应该关闭开始<select
标记,否则<option value='1'
会进入<select
,浏览器将无法呈现它。
这是修复:
echo 'SSH Timeout: <select name="ssh_timeout">';
$time = array('1','5','15','30','60');
foreach ($time as $value) {
if (15 == $value) {
echo "<option value='$value' selected>$value seconds</option>";
}
else{
echo "<option value='$value'>$value seconds</option>";
}
}
echo '</select>';