<?
$textFileName = 'filename.txt';
$strToDel = the_string;
$s = implode('', file($textFileName));
$p = strpos($s, $strToDel);
$len = strlen($strToDel);
if($p) {
$s = substr($s, 0, $p) . substr($s, $p+$len);
rename($textFileName, $textFileName . '~');
$f = fopen($textFileName, w);
fwrite($f, $s);
fclose($f);
}
?>
> -----Original Message-----
> From: Stevenson, Christopher
> [mailto:[EMAIL PROTECTED]]
> Sent: 3 iulie 2001 11:35
> To: '[EMAIL PROTECTED]'
> Subject: Deleting a string from a text file
>
>
> Hello, folks. I'm relatively new to this.
>
> Would anyone be willing to give me some code that will delete
> the first
> occurrence of a string from a text file?
>
> Thanks,
> Chris.
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]