Good day. There is a list (select). The script should parse the names of the php files in the directory, then display them in a drop-down list. And it outputs, but it is crooked. It turns out that the name of each new file is placed in a separate drop-down list, but it is necessary, that in one.

$dir = '../'; $f = scandir($dir); foreach ($f as $file){ if(preg_match('/\.(php)/', $file)){ echo '<select><option>'.$file.'</option></select>'; echo'<br>'; } } 

what am I doing wrong ?

    1 answer 1

    Well, you take echo '<select> for the limits of the cycle

     $dir = '../'; $f = scandir($dir); echo '<select>'; foreach ($f as $file){ if(preg_match('/\.(php)/', $file)){ echo '<option>'.$file.'</option>'; } } echo '</select>'; 
    • thanks, it's okay, I'm just a crab - qaz qaz
    • @qazqaz Happens :) - rjhdby