trecool999 Posted February 13, 2007 Share Posted February 13, 2007 Ok, I've got this to work: <?php echo "<form> <select name=\"Files\">\n"; $dirpath = "./"; $dh = opendir($dirpath); while (false !== ($file = readdir($dh))) { if(substr($file, -4, 4) == '.txt') { if (!is_dir($dirpath . '/' . $file)) { $f = htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file))); echo ' <option value="' . $file . '" onClick="form1.Title.value += \'' . $f . '\'">' . $f . "</option>\n"; } } } closedir($dh); echo "</select> </form>"; ?> But I need it so it doesn't capitalise the first letter when you copy it, or if it is easier, when it displays it in the list... This is probably really obvious for some of you, so don't insult me. Link to comment https://forums.phpfreaks.com/topic/38291-solved-problem/ Share on other sites More sharing options...
shoz Posted February 13, 2007 Share Posted February 13, 2007 Remove the ucfirst call $f = htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file))); Link to comment https://forums.phpfreaks.com/topic/38291-solved-problem/#findComment-183511 Share on other sites More sharing options...
trecool999 Posted February 13, 2007 Author Share Posted February 13, 2007 Uh... isn't that the bit that removes the .txt extension? Because I need to keep that... Never mind, I reread what you wrote and it works great, thanks . Link to comment https://forums.phpfreaks.com/topic/38291-solved-problem/#findComment-183543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.