When reading in a text file via PHP as followed:
$file_handle = fopen("L:\\file.txt", "rb");
while (!feof($file_handle) )
{
$line_of_text = fgets($file_handle);
$parts = explode('=', $line_of_text);
echo "<option value=\"$parts[0]\">$parts[0]</option>";
}
fclose($file_handle);
… the HTML source code ends up looking like:
<option value="AACM
">AACM
</option><option value="Academic Registry
">Academic Registry
</option><option value="Admin
">Admin
.. and so on. Very messy! Is there a way to prevent it? Ideally I’d like it formatted properly as:
<option value="AACM">AACM</option>
<option value="Academic Registry">Academic Registry</option>
… etc.
Is this possible?
Thanks 🙂
1 Answer