Start new column when readdir moves to new dir

余生颓废 提交于 2019-12-02 09:47:44

Achieved with the following code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>

<?php
echo '<table class="table"><tr>';
$folders = @scandir('Users');  
    foreach($folders as $item):
     if ((substr($item, 0, 1) == '.') || (preg_match("/\.php$/", $item)))
                continue;
    ?>
    <td align="top">
          <table width="220" border="1" valign="top">
               <tr><th width="210" valign="top"><?php echo $item;?></th></tr>
              <?php
               if (is_dir("Users/$item"))
            $target_folders = @scandir("Users/$item/uploaded/");
                foreach($target_folders as $target_item){

                if ((!preg_match("/^[.]/",$target_item)) || (!is_dir("Users/$item/uploaded/$target_item"))){
                if ((substr($target_item, 0, 1) == '.'))
                   continue;     

                   ?><tr><td><?php echo $target_item ;?></td></tr><?php

                }
                }

                   ?>
          </table>
</td>
    <?php
endforeach;

echo '</tr></table>';
?>


<style type="text/css">

    td {
vertical-align: top;
}



</style>
</body>
</html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!