using this code
<?php
foreach (glob("*.txt") as $filename) {
$file = $filename;
$contents = file($file);
$string = implode($contents);
echo $string;
echo "<br></br>";
}
?>
i can display the contants of any txt file in the folder the problem is all the formating and so on from the txt file is skipped
the txt file looks like
#nipponsei @ irc.rizon.net presents:
Title: Ah My Goddess Sorezore no Tsubasa Original Soundrack
Street Release Date: July 28, 2006
------------------------------------
Tracklist:
1. Shiawase no Iro On Air Ver
2. Peorth
3. Anata ni Sachiare
4. Trouble Chase
5. Morisato Ka no Nichijou
6. Flying Broom
7. Megami no Pride
8. Panic Station
9. Akuryou Harai
10. Hore Kusuri
11. Majin Urd
12. Hild
13. Eiichi Soudatsusen
14. Goddess Speed
15. Kaze no Deau Basho
16. Ichinan Satte, Mata...
17. Eyecatch B
18. Odayaka na Gogo
19. Heibon na Shiawase
20. Kedarui Habanera
21. Troubadour
22. Awate nai de
23. Ninja Master
24. Shinobi no Okite
25. Skuld no Hatsukoi
26. Kanashimi no Yokan
27. Kousaku Suru Ishi
28. Dai Makai Chou Kourin
29. Subete no Omoi wo Mune ni
30. Invisible Shield
31. Sparkling Battle
32. Sorezore no Tsubasa
33. Yume no Ato ni
34. Bokura no Kiseki On Air Ver
------------------------------------
Someone busted in, kicked me and asked why there was no release
of it. I forgot! I'm forgetting a lot...sorry ;_;
minglong
i the result i get looks like
#nipponsei @ irc.rizon.net presents: Title: Ah My Goddess Sorezore no Tsubasa Original Soundrack Street Release Date: July 28, 2006 ------------------------------------ Tracklist: 1. Shiawase no Iro On Air Ver 2. Peorth 3. Anata ni Sachiare 4. Trouble Chase 5. Morisato Ka no Nichijou 6. Flying Broom 7. Megami no Pride 8. Panic Station 9. Akuryou Harai 10. Hore Kusuri 11. Majin Urd 12. Hild 13. Eiichi Soudatsusen 14. Goddess Speed 15. Kaze no Deau Basho 16. Ichinan Satte, Mata... 17. Eyecatch B 18. Odayaka na Gogo 19. Heibon na Shiawase 20. Kedarui Habanera 21. Troubadour 22. Awate nai de 23. Ninja Master 24. Shinobi no Okite 25. Skuld no Hatsukoi 26. Kanashimi no Yokan 27. Kousaku Suru Ishi 28. Dai Makai Chou Kourin 29. Subete no Omoi wo Mune ni 30. Invisible Shield 31. Sparkling Battle 32. Sorezore no Tsubasa 33. Yume no Ato ni 34. Bokura no Kiseki On Air Ver ------------------------------------ Someone busted in, kicked me and asked why there was no release of it. I forgot! I'm forgetting a lot...sorry ;_; minglong
embed the text file content between
<pre></pre>
tagsAs several of the other responses mentioned, it greatly depends upon the page in which you're displaying the output.
Raw Text Output
If you're not adding any other content or HTML to the page. Simply change the HTTP Content-Type header to "text/plain"; that is:
As always, HTTP headers must be sent before any content is sent to the browser.
(X)HTML Output
Replacing
\n
's with<br/>
will not fix whitespace truncation issues; that is, the removal of adjacent spaces and/or tabs. The easiest way to get around this, also as previously mentioned, is to use the<pre>
tag to enclose the contents of the file. Unfortunately, this is not enough to satisfy XHTML. There are a number of symbols that are invalid in XML unless they are properly escaped, notably including:&
,<
, and>
.Thankfully, this is also an easy fix using the
str_replace
method:write your text in a .txt file and redirect to url corresponding to that file
php example code
contents of allow.txt are
contents of deny.txt are
contents of php file