English 中文(简体)
PHP在将产出按档案名称分类的同时,重复多份文本档案的内容——
原标题:Trying to echo contents of multiple text files while sorting the output by the file name - PHP

I m 不是开发商,而是现在的缺电开发商。 在过去几周里,我在这里和其他地点找到了许多答案,但最近的问题使我感到困惑不解。 I KNOW是一个简单的答案,但我不问谷歌正确的问题。

第一, 我不得不使用文本档案,因为我没有访问过数据库(在我工作的地方,排在右线下)。

不管怎么说,我需要看一看存放在那里的文本档案目录,打开每个档案,展示少量文本,同时确保我所展示的案文按档案名称分类。

我知道...... 最后,我进行了分类,我知道如何读到目录并显示档案的内容,但我有了一个时间把这两个概念合并在一起的黑板。

谁能提供帮助? 我现在用的是文字,我重复了分类的档案名称,没有问题。 我认为,我行的法典行将读到档案的内容,然后显示,这只是重复一线的中断,而不是档案的内容。 这是迄今为止的《第一号法典》——它只是一部测试法,以便我能够发挥功能。

<?php
$dirFiles = array();
if ($handle = opendir( ./event-titles )) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            $dirFiles[] = $file;
        }
    }
    closedir($handle);
}
sort($dirFiles);
foreach($dirFiles as $file)
{
    $fileContents = file_get_contents($file);//////// This is what s not working
    echo $file."<br>".$fileContents."<br/><br/>";
}
?>

帮助? iii

纽约总部

问题回答

$files = scandir ( ./event-titles >>,将各种档案名称重新贴在存档单上。 届时,你会这样做。

foreach($files as $file)
{
    $fileContents = file_get_contents( ./event-titles/ .$file);
    echo $file."<br/>".$fileContents."<br/><br/>";
}

请注意,我使用档案中的目录名称,因为档案名称本身将产生文档_get_contents,以查阅目前的目录,而不是你在目录中注明的目录。





相关问题
How do I sort enum members alphabetically in Java?

I have an enum class like the following: public enum Letter { OMEGA_LETTER("Omega"), GAMMA_LETTER("Gamma"), BETA_LETTER("Beta"), ALPHA_LETTER("Alpha"), private final String ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Linq operations against a List of Hashtables?

I m working with a set of legacy DAO code that returns an IList, where each Hashtable represents the row of a dynamically executed SQL query. For example, the List might contain the following records/...

C++ Array Sort Me

Stuck on an array sorter. Have to sort numbers from largest to smallest. I m trying two loops (one nested in the other). Here s the code: int counter=0; // inner counter int counter2=0; // outer ...

Can I Nest OrderBy in .NET?

This doesn t seem to work as I intend. VB.NET: Dim x = Model.Discussions.OrderByDescending(Function(d) d.Messages.OrderByDescending(Function(m) m.Sent).First.Sent) For Each d As Discussion In x ....

sorting elements javascript

I m looking for a way to sort my elements, but it isn t as easy as it sounds. Please let me explain My elements are grouped per 6 elements (thumbnails), each x represents a thumbnail However all ...

热门标签