Re: Copy and read a file

From: Date: Fri, 18 Apr 2003 16:12:41 +0000
Subject: Re: Copy and read a file
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-27168@lists.php.net to get a copy of this message
On Fri, 2003-04-18 at 06:04, Miguel Brás wrote: > Hi gents, > > I wanna copy a file from a webserver to my webserver everytime someone runs > the script A. > > Someone gave me the following lines for it: > > ****************** > $fp = fopen ("http://www.ivan.ivao.org/whazzup.txt", > "r"); > > while (!feof ($fp)) > { > $buffer = fgets($fp, 10000); > $fo = fopen ("data_status.txt","a+"); > fputs($fo,$buffer); > } > fclose ($fp); > fclose ($fo); > > ****************** > > For sure that this works, but it appends the new file, and i want to delete > all the old data and write the new one on the begin of the file. > > Any idea for it? > > The other part is that i wanna start on a specific point of the file and > make a search for a word. If i find the word, it continues to look until > eof. Then it returns me all the data found. Any help here also? > > Miguel Change your "a+" in the fopen() call to "w+" and then read this: http://www.php.net/manual/en/function.fopen.php -- Dave Smith System Programmer, BYU CS Department GPG Fingerprint: F907 A5C6 17AE C55D CE33 9F05 A829 B63C 99AE 2919

Attachment: [application/pgp-signature] This is a digitally signed message part signature.asc
« previous php.db (#27168) next »