I'm using PHP to generate the select menu for an HTML web form as follows:
$foods = array(
'1' => 'fruit',
'2' => 'pizza',
'3' => 'bread',
'4' => 'nuts',
);
Here's the code for the HTML select input:
<select id="food" name="food">
<option value="*">- No Selection - </option>
<?php
$output = "";
$selected = false;
foreach($foods as $food => $value) {
$food = htmlspecialchars($food);
$output .= "<option value=\"$food\"";
if ($food == $pcSymptomSearch) {
$selected = true;
$output .= " selected";
}
$output .= ">$value</option>";
}
echo $output;
?>
</select>
I've noticed when viewing the source in Safari/Mac OS X that the select input generated by PHP appears on one line like this, which makes reading/debugging a bit tricky:
<option value="1">fruit</option><option value="2">pizza</option><option value="3">bread</option><option value="4">nuts</option> </select>
Is there a way to make each option appear on one line like this:
<option value="1">fruit</option>
<option value="2">pizza</option>
<option value="3">bread</option>
<option value="4">nuts</option>
</select>