If i have a text file that contain data of names:
John
Ham
Joe
Tope
Nalawas
i want php to look for Joe and remove it from the list. Any idea?
my idea:
<?php
$lines = file('user.txt');
$word = '';
$result = '';
foreach($lines as $line) {
if(substr($line) == 'joe') {
$result .= $word."\n";
} else {
$result .= $line;
}
}
file_put_contents('user.txt', $result);
?>
this code is not working i want to use preg-replace