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 keep this line.
Delete this line.
Keep this one too.
] delete lines from text file
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 keep this line.
Delete
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
the file, open it again for writing, write the text to
the file, and then close it.
Hope this helps,
Hugh
- Original Message -
From: Matt Palermo [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, June 05, 2003 8:53 PM
Subject: [PHP] delete lines from text file
Can anyone help me
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
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
:-)
- CS
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
$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
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...
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
10 matches
Mail list logo