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
Searching in a text file
Moderator: General Moderators
Searching in a text file
- Attachments
-
- log.zip
- (522 Bytes) Downloaded 2 times
Re: Searching in a text file
Is anyone there who can help on this?
Re: Searching in a text file
I'm too lazy to download a zip, open it up, and stick it in a text editor.
It's only 522 bytes - how about you post it in [syntax=php][/syntax] tags?
It's only 522 bytes - how about you post it in [syntax=php][/syntax] tags?
Re: Searching in a text file
Too lazy?
In this case why you even read the post?
I have the same file which is 3 mb, so I have attached a small part of the file.
I cannot copy past it as If I will open with any text editor, the text showing up just right.
If I open troug php, the file is readed in a strange format.
So that why.
In this case why you even read the post?
I have the same file which is 3 mb, so I have attached a small part of the file.
I cannot copy past it as If I will open with any text editor, the text showing up just right.
If I open troug php, the file is readed in a strange format.
So that why.
Re: Searching in a text file
Ok, I ha the solution.
I have no idea of the file format, but if i convert every single line to ASCII, then convert the ASCII to char, then it is ok.
ereg or eregi or regex can be perform on it.
I have no idea of the file format, but if i convert every single line to ASCII, then convert the ASCII to char, then it is ok.
ereg or eregi or regex can be perform on it.