Easy file question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Doolittle
Forum Newbie
Posts: 19
Joined: Sun May 04, 2003 11:45 pm

Easy file question

Post by Doolittle »

I've searched a bunch of places but haven't had much luck... How would you write into a file with multiple lines... lets say from an array and each
part of the array has its own line... I believe I have done it before I have
just completely forgotten how to!

I've tried using the "\n" and still doesn't work...

Here is my code:

Code: Select all

$xї0] = "Hello";
$xї1] = "waldo";

$x = implode("\n", $x);

$fp = fopen("x.txt", "wt");
fwrite($fp, $x);
fclose($fp);
Thanks in advance!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

\n should do the trick.
How and where (OS) do you open/read x.txt again?
Post Reply