dongren1977 2018-01-10 01:51
浏览 7
已采纳

如何从显示目录文件中删除点

My output display dots so i want to delete the dots

<?php
include 'config.php';
if(isset($_POST['btn-upload']))
{    
$log_directory = ('/XAMPP/htdocs/mydoc');
$results_array = array();
if (is_dir($log_directory))
{
        if ($handle = opendir($log_directory))
        {
                while(($file = readdir($handle)) !== FALSE)
                {
                        $results_array[] = $file;
                }
                closedir($handle);
        }
}
foreach($results_array as $value)
{
    echo $value . '<br />';
}
}
?>

But the output

I want to throw the dots..

Any solution to delete the dots ?

  • 写回答

2条回答 默认 最新

  • dongzhong5756 2018-01-10 02:05
    关注

    readdir() always return "." & "..". So you just have to validate and skip them as shown in the example #2 of the manual

    <?php
    if ($handle = opendir('.')) {
        while (false !== ($entry = readdir($handle))) {
            if ($entry != "." && $entry != "..") {
                echo "$entry
    ";
            }
        }
        closedir($handle);
    }
    ?>
    

    http://php.net/manual/en/function.readdir.php

    Resulting in

    [...]
            if ($handle = opendir($log_directory))
            {
                    while(($file = readdir($handle)) !== FALSE)
                    {
                        if ($file != "." && $file != "..") {
                            $results_array[] = $file;
                        }
                    }
                    closedir($handle);
            }
    [...]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂