Hi planetsim,
This doesn't work properly... it deletes some users for nothing..
and it's not even removing the blank lines, it just create more.. 😕
how can I fix this?
Your code:
$filecontents = file("login.txt");
$newfile='';
for ($i=0;$i<=sizeof($filecontents);$i++) {
if ($filecontents[$i]!=' ') {
$newfile .= $filecontents[$i]."\n"; //creates the new file
}
}
//now open the file again for writing
$fp=fopen("login.txt","a+");
fwrite($fp,$newfile);
fclose($fp);
I tried to use str_replace function.. but it still leave a blank line.. 🙁
see:
$search = "$nickname";
$contents = file_get_contents ("login.txt");
$replace="";
$contents = str_replace ($search, $replace, $contents);
$handle = fopen ("login.txt", "w");
fwrite ($handle, $contents);
fclose ($handle);
pls, could you fix your code?..
thanx!
-GM