jdavis Posted November 19, 2007 Share Posted November 19, 2007 Hello, I am developing a PHP/MySQL project and as part of my initial setup and configuration scripts, the users can select a skin for the application, and a variable value ($skin) is updated to set the current skin, this works ok on it's own, but currently the user must manually type the skin name in a free-text box. Ideally this needs to be a drop-down option box, and I would like this to be populated by listing the sub-folders within the '/skins' folder, so that it's always up to date. The folder structure looks like this: /skins /skins/skin1 /skins/skin2 /skins/skin3 How can I use PHP to generate a list of the current sub-directories in 'skins' and populate the drop-down list? thanks, Jonathan Quote Link to comment Share on other sites More sharing options...
trq Posted November 19, 2007 Share Posted November 19, 2007 <?php $skins = scandir('/skins'); foreach ($skins as $skin) { if (is_dir('/skins/' . $skin)) { echo $skin . "<br />"; } } ?> Quote Link to comment Share on other sites More sharing options...
jdavis Posted November 19, 2007 Author Share Posted November 19, 2007 That looks perfect! Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.