我有一個FOR循環列出了某個目錄中的所有文件。其中一個結果也是INDEX.PHP,這是我不需要的結果。這是循環的第一個結果/輸入...忽略第一個循環結果
有什麼辦法可以跳過這第一個結果,並從第二個結果開始循環? 請幫忙。
<?php
$myDirectory = opendir('.');
while($entryName = readdir($myDirectory))
{
$dirArray[] = $entryName;
}
closedir($myDirectory);
$indexCount = count($dirArray);
echo '<h5>There are ' . $indexCount . ' files in the Media Center</h5>';
sort($dirArray);
echo '<table width="100%">';
echo '<tr>';
echo '<th width="33%" align="center" class="admin_th" style="border-radius: 10px 0 0 0">Download</th>';
echo '<th width="33%" align="center" class="admin_th">Filetype</th>';
echo '<th width="33%" align="center" class="admin_th" style="border-radius: 0 10px 0 0">Filesize (in bytes)</th>';
echo '</tr>';
for($index = 0; $index < $indexCount; $index++)
{
if (substr("$dirArray[$index]", 0, 1) != ".")
{
echo '<tr><td width="33%" align="center" class="admin_td-even"><a href="' . $dirArray[$index] . '">' . $dirArray[$index] . '</a></td>';
echo '<td width="33%" align="center" class="admin_td-odd">';
echo strtoupper(substr($dirArray[$index], -3));
echo '</td>';
echo '<td width="33%" align="center" class="admin_td-even">';
echo filesize($dirArray[$index]);
echo '</td>';
echo '</tr>';
}
}
echo '</table>';
?>
發佈您的代碼。 – m0skit0 2012-04-06 12:05:56