Re: deleting lines in a textfield
| From: | Adrian Ciutureanu | Date: | Mon, 22 Apr 2002 16:40:35 +0000 |
| Subject: | Re: deleting lines in a textfield | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-94028@lists.php.net to get a copy of this message | ||
<?php
$file_name = 'test.txt';
$line_no_to_delete = 2;
$f = fopen($file_name, 'rw+');
$s = explode("\n", fread($f, filesize($file_name)));
unset($s[$line_no_to_delete - 1]);
fseek($f, 0);
fputs($f, implode("\n", $s));
fclose($f);
?>
"Kris Vose" <KVose@alidaconnection.com> wrote in message
news:0D192E12994BF64B84EB7BE6D960E3900D6803@alidamail.alidaconnection.com...
How would you go about deleting a specific line in a textfield via PHP? For
example, I want to delete line 2 only and save the changes. How would I go
about doing this using fopen and fwrite?
Kris