Re: [PHP] Delete Line from File?

2004-09-13 Thread Nick Wilson
* and then John Holmes declared > >Whats the easiest/best way to do that with php? > >just replace the line with ''? > > Yes, basically. You have to read the file, replace the part you don't want > with an empty string and then re-write the file. If the file is small and > you're using file

Re: [PHP] Delete Line from File?

2004-09-13 Thread John Holmes
From: "Nick Wilson" <[EMAIL PROTECTED]> Whats the easiest/best way to do that with php? just replace the line with ''? Yes, basically. You have to read the file, replace the part you don't want with an empty string and then re-write the file. If the file is small and you're using file() to read i

Re: [PHP] Delete Line from File?

2004-09-13 Thread zareef ahmed
Hi, some function with whihc you can do this file(); foreach(); zareef ahmed --- Nick Wilson <[EMAIL PROTECTED]> wrote: > Whats the easiest/best way to do that with php? > just replace the line with ''? > -- > Nick W > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe

[PHP] Delete Line from File?

2004-09-13 Thread Nick Wilson
Whats the easiest/best way to do that with php? just replace the line with ''? -- Nick W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] delete line

2003-08-14 Thread Rodney Green
I've been looking and haven't found anything on this. How do you open a file then select a line and delete that line? Thanks, Rod -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] delete line

2003-08-14 Thread Chris Boget
> I've been looking and haven't found anything on this. How do you open a file > then select a line and delete that line? Warning: untested. This is just to give you a general idea. $fileName = "blah.txt"; $lineToDelete = "Delete this line"; $fileArray = file( $fileName ); if(( $lineNum = arra

Re: [PHP] delete line

2003-08-14 Thread Robert Cummings
If your file isn't too large then you can use: $lineArray = file( $pathToYourFile ); unset( $lineArray[$lineNum - 1] ); if( ($fl = fopen( $pathToYourFile, "w+" )) !== false ) { foreach( $lineArray as $line ) { fputs( $fl, $line ); } fcl