0
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>';

That code doesn't show the first value which is 1 but instead it starts from 5 to 60. How do I fix it ?

3
  • Should work fine: 3v4l.org/Z0Ipm can't reproduce it. Commented Nov 6, 2016 at 3:15
  • 1
    you should close the opening <select...> tag :) Commented Nov 6, 2016 at 3:16
  • @Dekel OMG, how could I not see that, how careless of me lol Commented Nov 6, 2016 at 3:18

1 Answer 1

1

You should close the opening <select tag, otherwise the <option value='1' gets inside the <select and the browser will not render it.

This is the fix:

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>';
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.