View Single Post
Old 01-15-2008, 06:11 PM   #8 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

How about:
PHP Code:
foreach(glob('../categories/*'GLOB_ONLYDIR) as $dir)
{
    
$dir basename($dir);
    echo 
'<option value="'$dir'">'$dir'</option>';

We use GLOB_ONLYDIR as in Wildhoney's example to grab the paths to directories within ../categories, then grab only the directory name (using basename()), before outputting the option HTML element.
Aside: Note the use of commas to separate expressions for the echo statement, rather than concatenating to a string.
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
buildakicker (01-15-2008)