在某个文件夹中获取PHP文件

在某个文件夹中获取PHP文件,php,Php,我有一个包含5页的文件夹,我想得到每一页的链接、创建日期和标题 目前,我的做法如下: <?php function getActus() { return array( $message1 = array( 'date' => filectime("news/news1.php"), 'titre' => "News 1",

我有一个包含5页的文件夹,我想得到每一页的链接、创建日期和标题

目前,我的做法如下:

<?php
    function getActus()
    {
        return array(

                $message1 = array(
                    'date'  => filectime("news/news1.php"),
                    'titre' => "News 1",
                    'url'   => "/Serie_4/ex3/news/news1.php"
                 ),

                $message2 = array(
                    'date'  => filectime("news/news2.php"),
                    'titre' => "News 2",
                    'url'   => "/Serie_4/ex3/news/news2.php"
                 ),

                $message3 = array(
                    'date'  => filectime("news/news3.php"),
                    'titre' => "News 3",
                    'url'   => "/Serie_4/ex3/news/news3.php"
                 ),

                $message4 = array(
                    'date'  => filectime("news/news4.php"),
                    'titre' => "News 4",
                    'url'   => "/Serie_4/ex3/news/news4.php"
                 ),

                $message5 = array(
                    'date'  => filectime("news/news5.php"),
                    'titre' => "News 5",
                    'url'   => "/Serie_4/ex3/news/news5.php"
                 )
            );
    }
?>

我想动态地这样做,因为有时候我不知道那个文件夹上有多少页面

如何获取某个文件夹中的文件


我还想获取每页的标题,我指的是介于

之间的标题要检索目录中的文件列表,请签出:

要检索每个文件的修改时间,请执行以下操作:

要从页面中提取标题,请执行以下操作: http://stackoverflow.com/questions/13510124/regular-expression-to-get-page-title

我更喜欢asad的anwser:

$doc = new DOMDocument();
$doc->loadHTML($html);
$titles = $doc->getElementsByTagName("title");
echo $titles->item[0]->nodeValue;
但是您需要从文件而不是字符串加载:http://php.net/manual/en/domdocument.loadhtmlfile.php