I got an answer earlier today which can be found here: Searching multiple strings in one txt file
I got a good answer, but there seems to be one last issue with it. When I am searching a file which exceeds 10 mb it doesn't show any more results.
This code allows me to search multiple strings. Which is what I want.
The code:
<?php
$search1 = "value 1";
$search2 = "value 2";
$lines = file('my_file.txt');
foreach($lines as $line)
{
if(stristr($line,$search1) || stristr($line,$search2))
echo " $line <br>";
}
?>
I would have no clue. I had code which could only search one string but it could go over 10 mb+ files. But now I want to search multiple strings and that is why I have this issue now.
The script which works over 10 mb+, this is the one I used earlier before I got the code above - But can only search one string, but I want to search multiple strings at once.
$search = $_GET["search"];
$search2 = $_GET['search2'];
$logfile = $_GET['logfile'];
// Read from file
$file = fopen($logfile, "r");?>
<head><title>Searching: <?php echo $search ?></title></head>
<?php
while( ($line = fgets($file) && $line2 = fgets($file))!= false)
{ if (stristr($line, $search)) { } if (stristr($line2, $search2)) { }
?><font face='Arial'> <?php $lines = $line + line2; ?><?php echo $lines ?></font><hr><p><?php
}
Thank you for reading.