Jump to content


printing out the whole contents of a file


2 replies to this topic

#1 TheUnforgiven512

    Young Padawan

  • Members
  • Pip
  • 102 posts

Posted 23 May 2006 - 09:16 PM

This is what I have:
<?php 
$file = file_get_contents("test.txt");
print($file);
?>

Test.txt has

Quote

1
2
3
4
5
6
7

but when I upload it and test it out, I get:

Quote

1 2 3 4 5 6 7

How can I make it copy the new line or make a new line after each number?

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 23 May 2006 - 10:30 PM

What you see is "1 2 3 4 5 6 7", but that's not what you get. If you viewed the source, you're getting the exact file as you uploaded it, but browsers don't care about line breaks.

This is also a rather common question:
http://www.pixel2lif...showtopic=15669
http://www.pixel2life.com/forums/index.php...indpost&p=78054

#3 TheUnforgiven512

    Young Padawan

  • Members
  • Pip
  • 102 posts

Posted 24 May 2006 - 03:13 AM

ah okay those links helped. thanks





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users