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
file()
returns an array with the lines of the file.If you implode those without glue there will be no linebreaks at all.
So, either get the contents unmodified using
file_get_contents()
(which gives you a string), or glue the implode with newline orPeter Stuifzand had the right idea, passing a second argument to the implode function, so I won't address that. What I will point out is that your own
echo "<br></br>";
code does not produce valid HTML. If you're doing HTML and want 2 line breaks, doecho "<br><br>";
and if you're doing XHTML and want 2 line breaks, doecho "<br/><br/>";
. Otherwise, if you only want 1 line break, the HTML br tag does not have a closing tag, so</br>
is not necessary in either case.You have to add HTML line break elements to the physical line breaks. You could use the
nl2br
function to do that:Additionally I would use the
file_get_contents
function rather than the combination offile
andimplode
.If this isn't part of an HTML document, you need to change the content type:
If it is part of an HTML document, just do this:
Alternatively you can replace newlines with breaks:
Or you could just put it into a textarea like this:
But only if you can and it turns out right.
The
implode
defaults to an empty string. You should callimplode
something like this: