【发布时间】:2017-07-12 19:56:07
【问题描述】:
我对此感到困惑......我试图列出目录中的所有文件并从中提取一些信息(特别是它们的 csv 文件......我需要打印出每个文件的第一行。)
好吧,它实际上只会在浏览器中打印
代码:
<style>
.demo {
border:3px solid #000000;
border-collapse:collapse;
padding:5px;
}
.demo th {
border:3px solid #000000;
padding:5px;
background:#F0F0F0;
}
.demo td {
border:3px solid #000000;
padding:5px;
background:#DCC4FD;
}
</style>
<?php
exec('ulimit -S -n 9999999999');
echo "Current Simulations for the next 24 hours.";
$path = ".";
$dh = opendir($path);
$i=1;
echo '<html><body><table class="demo">\n\n';
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != ".." && $file != "index.php" && $file != ".htaccess" && $file != "error_log" && $file != "cgi-bin") {
if(fnmatch('*.csv', $file)) {
$content = file($file);
echo "<td> $file </td>";
echo "\n<td>".str_replace(array(","), array("</td><td>", "</td>\n<td>"), $content[1])."</td>";
echo "</tr>";
}
$i++;
}
}
fclose($handle);
closedir($dh);
?>
【问题讨论】:
标签: php html directory limit readdir