Break it down one step at a time.
Use the [man]file()[/man] function to load each line of the file into an array.
Then use [man]preg_replace()[/man] to get rid of your ABC strings... Here's a code for that.
<?php
// The $subject_array is the output from your file() function.
$subject_array = array("abc123", "123", "456", "789", "abc867");
$pattern = '/abc/';
$replacement = '';
foreach($subject_array as $v) {
$output_array[] = preg_replace($pattern, $replacement, $v);
}
print_r($output_array);
?>
Once you have your $output_array, you can then use the [man]fopen()[/man] (in w mode) to truncate your file and open the file in write mode with the pointer at the beginning of the file.
Then use a foreach statement to loop through your output array and use [man]fwrite()[/man] to write each of your lines to the file...
I know I didn't give it to you line for line, but I've given you everything you need to be able to accomplish your goal. (Feed a man a fish, he eats today. Teach a man to fish and he will eat for life.) I hope this helps you out.