Easy solution to this basic HTML coding need posted over at Stack Overflow by a random clever bloke. Thanks RCB.
<?php $fc = file_get_contents('./test.txt'); $fc = utf8_encode ( $fc ); $lines = explode("n", $fc); $html = '<select>'; foreach($lines as $line) $html .= '<option value="' . $line . '">' . $line . '</option>'; $html .= '</select>'; echo $html; ?>
My only issue was with UTF-8 characters coming through garbled. Bodged a workaround using this encode entities plug-in for Dreamweaver.
Last updated on 1st February 2019
Leave a Reply