【发布时间】:2014-07-22 03:01:47
【问题描述】:
这是我之前回答的问题的第二部分Php Browsing Multiple Directories
现在我已经让脚本完美地读取了目录,是否可以将文件列表的结果加载到新页面中,如races.php 以“美化”
这是列出文件的方式Example of Files being listed from server 我真的很想将它显示在网站内,而不是跳到 apache 服务器列表中,这样它对用户更友好。
编辑 我认为我在理论上试图做的是,一旦脚本扫描了目录,它就会将它放入一个名为 $files 的数组中,然后 foreach 循环所有文件夹,但我现在卡住的地方是我如何通过它$file 进入新页面?并使其显示文件夹内的内容:)
再次感谢和抱歉在这里尝试学习的超级新手!
脚本文件生成列表并单击每个文件内的文件:
<?php
$files = array();
$dir = opendir('races/ob/');
// $dir = opendir('races/ob/');
while(false != ($file = readdir($dir))) {
if(($file != ".") and ($file != "..") and ($file != "index.php")) {
$files[] = $file; // put in array.
}
}
natsort($files); // sort.
// print.
foreach($files as $file) {
echo("<span class='txt-spacing'><a href='races/ob/$file'>$file</a> <br />\n</>");
}
?>
【问题讨论】:
-
所以你把脚本放在你想要的地方?
-
对不起,我不明白你的意思?
-
目前是什么阻止您将其放入races.php 或任何其他文件中?
-
如何使链接正确加载?
-
你需要对当前的问题给出更全面的解释。