I'm assuming glob cannot open large files, as every time it tries to open 2 big files at once, it outputs:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 371490864 bytes) in C:\xampp\htdocs\mywebsite\results.php on line 15
Here is results.php:
<?php
error_reporting(E_ERROR | E_PARSE);
$file = glob('db/*', GLOB_BRACE);
$searchfor = $_GET['q'];
if (!$_GET['q']) {
echo "Enter something.";
}
else {
// get the file contents, assuming the file to be readable (and exist)
$contents = implode(array_map(function ($v) {
return file_get_contents($v);
}, glob(__DIR__ . "/db/*"))); // this is line 15
// escape special characters in the query
$pattern = preg_quote($searchfor, '/');
// finalise the regular expression, matching the whole line
$pattern = "/^.*$pattern.*\$/m";
// search, and store all matching occurences in $matches
if (preg_match_all($pattern, $contents, $matches))
{
echo '<center>Results</center>';
echo "<pre>";
echo implode($matches[0]);
echo "</pre><br></div>";
}
else
{
echo "<center><br>No results found</center>";
}
}
whats suppose to happen is to output everything from those two files with the query that I add into the search engine, instead this memory error thing shows up.
Maybe there's something I'm missing or there's a way around it?
I've tried researching but nothing really popped up. Help?