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 );
}
fclose( $fl );
}
Note that the above has not been tested. If your file is quite large,
you will probably be better off reading in each line one at a time and
writing out the line to a temporary file when it isn't the line your are
trying to omit. Then replace the original file with the temporary file.
HTH,
Rob.
On Tue, 2003-08-12 at 11:38, Rodney Green wrote:
> 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
>
>
--
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the |
| stuff of nightmares grasp for your soul. |
`---------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php