![](/img/trans.png)
[英]Getting a list of directories and files from root directory from remote site via FTP using CURL and PHP
[英]Getting Directories from a folder in the root directory PHP
我有一個名為threads的文件夾,並且在該文件夾中還有其他文件夾。 我在將這些文件夾讀取到數組中,然后將它們放在選擇框中時遇到麻煩。 這是我的代碼。
<select value="Please Select a Genre" >
<?php
$threads = array();
if ($handle = opendir('/Threads/')) {
while (false != ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
array_push($threads,"$file");
print_r ($threads);
}
}
sort($threads);
print_r ($threads);
for ($i = 0; $i < count($threads); $i++) {
print "<option value=\"$threads[$i]\">$threads[$i]</option>";
}
closedir($handle);
?>
</select>
<br />
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
</form>
</center>
</body>
</html>
您的源代碼有錯誤。
您缺少結束語}
<select value="Please Select a Genre" >
<?php
$threads = array();
if ($handle = opendir('/Threads/')) {
while (false != ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
array_push($threads,"$file");
print_r ($threads);
}
}
}
sort($threads);
print_r ($threads);
for ($i = 0; $i < count($threads); $i++) {
print "<option value=\"$threads[$i]\">$threads[$i]</option>";
}
closedir($handle);
?>
</select>
<br />
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
</form>
</center>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.