RE: [PHP] delete lines from text file

2003-06-05 Thread Martin Towell
I think you'll have to read the file manually (file() would prob be the best bet) and manually find/delete the line and then rewrite the file. Martin -Original Message- From: Matt Palermo [mailto:[EMAIL PROTECTED] Sent: Friday, June 06, 2003 1:54 PM To: [EMAIL PROTECTED] Subject: [PHP]

Re: [PHP] delete lines from text file

2003-06-05 Thread R'twick Niceorgaw
On Thursday 05 June 2003 11:53 pm, Matt Palermo wrote: Can anyone help me figure out how to search for a string in a text file, then delete the whole line of text that it occurs in? For example: I have a text file which contains the following. //** text.txt ** Keep this line. Also

Re: [PHP] delete lines from text file

2003-06-05 Thread Hugh Danaher
Matt, Try something like: ? $fp=fopen(file_name.txt,r); while (feof($fp)) { $line=fget($fp,100); // grabs text to end of line or 100 characters whichever comes first if (!preg_match(/delete/,$line)) { $new_line.=$line; } } fclose($fp); $fp=fopen(file_name.txt,w); fwrite($fp,$new_line)

Re: [PHP] delete lines from text file

2003-06-05 Thread Hugh Danaher
My bad: while (!feof($fp)) instead of what I wrote earlier. - Original Message - From: Hugh Danaher [EMAIL PROTECTED] To: Matt Palermo [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Thursday, June 05, 2003 10:59 PM Subject: Re: [PHP] delete lines from text file Matt, Try something like

Re: [PHP] # of lines in a file

2002-12-09 Thread John Nichel
You could try... $file = ( /path/file.ext ); $lines = sizeof ( $file ); [EMAIL PROTECTED] wrote: Hey guys, I've been searching the manual for a way to grab the number of lines in a file and read a particular line from it, however I found no solution to my problem so I'm wondering if any of

Re: [PHP] # of lines in a file

2002-12-09 Thread Adam Voigt
$f = fopen(filename,r); $data = "" fclose($f); $data = "" $lines = count($data); $certainline = $data[linenumberyouwant]; Replace filename in both places, and linenumberyouwant. On Mon, 2002-12-09 at 11:58, [EMAIL PROTECTED] wrote: Hey guys, I've been searching the

RE: [PHP] # of lines in a file

2002-12-09 Thread John W. Holmes
Hey guys, I've been searching the manual for a way to grab the number of lines in a file and read a particular line from it, however I found no solution to my problem so I'm wondering if any of you out there could help me file() will read the file into an array, one line per element, so...

Re: [PHP] # of lines in a file

2002-12-09 Thread Ray Hunter
Might not be the most secure way, but very fast... $lines = `cat file.txt | wc -l` That will give you the number of lines...but again not the best method... On Mon, 2002-12-09 at 09:58, [EMAIL PROTECTED] wrote: Hey guys, I've been searching the manual for a way to grab the number of lines