View Single Post
  #7 (permalink)  
Old 03-08-05, 02:20 AM
eddyvlad eddyvlad is offline
Wannabe Coder
 
Join Date: Sep 2003
Location: In The Bloody Pits Of Hell
Posts: 160
Thanks: 2
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by STphp
To delete a line, just make a form with a text field in where users submit their email address or something and call the field 'email' and use this to remove the line from the file:

PHP Code:

<?php
 
 $Lines 
file("users.txt");
 
$cLines count($Lines);
 
$dlete $_POST['email'];
 
   foreach(
$Lines as $Key => $Val) { 
 
    
$Data[$Key] = explode("|"$Val);
 
     if ( 
trim($Data[$Key][1]) == $dlete ) {
 
      unset(
$Lines[$Key]);
      
$fp fopen("users.txt""w");
      
$fw fwrite($fpimplode(''$Lines));
      
fclose($fp);
 
     }
 
   }
 
 print 
"Deleted";
 
 
?>
What this script do is actually take all the data from the .txt file and put all the lines into arrays, delete the array value of that line and overwrite the file with all the data.
I doubt there's a way to delete the line directly from the file.
__________________
Mr. Brown Eyes
Reply With Quote