Re: Reading first line of data file then erase it

From: Date: Thu, 28 Dec 2000 09:48:31 +0000
Subject: Re: Reading first line of data file then erase it
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32061@lists.php.net to get a copy of this message
Here's one way : $filename = 'test.txt'; // Open file as array $pieces = file ($filename); // Push away first piece into $firstline $firstline = array_shift($pieces); print $firstline; // Open file and write it out, and now // $firstline is gone. w+ is important. $fd = fopen($filename,'w+'); foreach ($pieces as $piece) { fwrite($fd,$piece); } Regards, Philip On Thu, 28 Dec 2000, Richard Kurth wrote: > I have data file that just contains unused IP address named > ipdata it looks like this with one IP address on each line > 205.345.345.23 > 205.345.345.24 > 205.345.345.25 > 205.345.345.26 > What I what to do is open it get the top IP address then erase that > address and close the file. > How would I do this. > I know that I open it with > $fp=fopen("ipdata","r+")or die("unable to open file ($ipdata)"); > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#32061) next »