Using flat text files

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
spudmclard
Forum Newbie
Posts: 16
Joined: Thu Oct 27, 2005 3:06 am

Using flat text files

Post by spudmclard »

Can anybody give me a pointer on what i would have to do to enable me to take an entry from one flat text file and move it to another.
ie.
FILE1 FILE2
a
b
c

to end up

FILE1 FILE2
a b
c

Sorry for being vague.
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: Using flat text files

Post by aerodromoi »

spudmclard wrote:Can anybody give me a pointer on what i would have to do to enable me to take an entry from one flat text file and move it to another.
ie.
FILE1 FILE2
a
b
c

to end up

FILE1 FILE2
a b
c

Sorry for being vague.
reading:

Code: Select all

$file= "xyz.dta";
$fp = fopen ($file, "r" );
$olddata = fread ($fp, filesize($file));
fclose ($fp);
writing:

Code: Select all

$access = fopen ($file, "w" );
fwrite ($access, $string, 800000 );
fclose ($access);
You'll have to chmod the file xyz.dta accordingly!

aerodromoi
Post Reply