I'm trying to spot non-standard characters in a text file.
I want to print out the offending lines.
I have this code but it just prints out all of the lines regardless of whats in it.
Am I missing something?
$handle = @fopen("some.txt", "r");
$count = 0;
if ($handle) {
while (!feof($handle)) {
$input = fgets($handle, 4096);
$output = preg_replace("/[^A-Za-z0-9 ]/","XXXXX",$input);
if (preg_match("@XXXXX@", $output))
{echo "Found Crap at line $count - $input <BR>";}
$count++;
}
fclose($handle);
}
My Text file has this in it
Alan Fox
ZenaRyle
Alán Fox
Bob Smith
James A`on
Bob Marley
Any help would be greatly appreciated ..... or a different way of doing it!