Hello All,
I have a file that is in binary format and I need to search it for a specific group of ascii codes. How can I do this with regular expressions in php?
I have tried various methods, but they are slow. What is my best method for searching (and extracting info from) potentially large files?
Here is the code I am using (which works, but it takes 5 seconds to run on a 400k file - many files will be 3 MB or more):
$searchValue = chr(43) . chr(39) . chr(179). chr(217) . chr(48);
$theFile = "c:/reports/employee.dcr";
$handle = fopen($theFile,"r");
while(! feof($handle))
{
$theChar = fgetc($handle);
$contents .= $theChar;
}
fclose($handle);
$p = strpos($contents,$searchValue);
print "FOUND: $p at " . date("hⓂs") . "<br>";
Thanks for the help!
Scott