HTML option selected Attribute

The selected attribute is a boolean attribute.
When present, it specifies that an option should be pre-selected when the page loads.
The pre-selected option will be displayed first in the drop-down list.

Basic Example

<!DOCTYPE HTML>
<html>
<head>
<title>Select option default</title>
</head>
<body>
	<select name="sel1">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="9" selected="selected">9</option>
		<option value="3">3</option>
	</select>
</body>
</html>

Example (in nested loops)

<?php
$array = '9,8,2,1';
$newar = explode(",", $array);
$dummy = 0;

$i = 0;

for ($i = 0; $i < 4; $i ++) {
    ?>
<select name="<?php echo $i ?>">
<?php
    for ($j = 0; $j < 4; $j ++) {
        if ($j == 0) {
            ?>
            <option value="<?php echo $newar[$dummy]; ?>" selected><?php echo $newar[$dummy]; ?></option>
            <?php
            $dummy++;
        } else {
            ?>
            <option value="<?php echo $j; ?>"><?php echo $j; ?></option>
            <?php
        }
        ?>
<?php
}
    ?>
</select>
<?php
}
?>