dreamwest Posted August 30, 2009 Share Posted August 30, 2009 this is my first go at file open and write. I need to delete a file on a specific line: This file contains lines like something|something something| something|something something|something So a error will script will output "ERROR on line 2 - something|" $handle = @fopen("1.txt", "r"); if ($handle) { $count = 1; while (!feof($handle)) { $buffer = trim(fgets($handle, 4096)); //echo $buffer."<br>"; $check = explode('|', $buffer); if ($check[1] == "" || $check[1] == " " ){ echo "ERROR on line {$count} - {$buffer}<br>"; } $count = $count +1; } fclose($handle); } Now all i need to do is delete that whole line from the file Quote Link to comment https://forums.phpfreaks.com/topic/172434-delete-line-in-file/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.