Searching in a text file
Posted: Sat Mar 28, 2009 5:39 pm
Dear All,
I am using the following code to display what I have in the uploaded file.
$file = $_FILES['file']['name'];
$handle = @fopen($file, "r");
if ($handle) {
while (!feof($handle)) {
$line = fgets($handle, 4096);
print(strlen($line).' - '. $line.'<br />');
}
fclose($handle);
}
The problem I have is that the attached file, I can display , but cannot search in.
Even the lengt of the string are much longer that should be.
I would like to search each line for string.
I have try strpos, preg_match etc.. but no luck.
I have attached to this forum the file in question.
Can someone tell me, tha using this file how can I search for sting in a line and display the line if match found?
Many thanks.
Regards,
Gabor
I am using the following code to display what I have in the uploaded file.
$file = $_FILES['file']['name'];
$handle = @fopen($file, "r");
if ($handle) {
while (!feof($handle)) {
$line = fgets($handle, 4096);
print(strlen($line).' - '. $line.'<br />');
}
fclose($handle);
}
The problem I have is that the attached file, I can display , but cannot search in.
Even the lengt of the string are much longer that should be.
I would like to search each line for string.
I have try strpos, preg_match etc.. but no luck.
I have attached to this forum the file in question.
Can someone tell me, tha using this file how can I search for sting in a line and display the line if match found?
Many thanks.
Regards,
Gabor