There are a few errors, missing chars etc. I've cleaned it up a bit. You also have no post data for "input", you would need to add something like the following:
<textarea name='input'></textarea>
As for the PHP, I don't understand the point of the file_get_contents part. Are you expecting the keywords to come from the html file, or is the user to enter the keywords and the text to filter? If you are putting keywords into $content and the text to search in $input, you could do something like this:
<?php
$content = file_get_contents("scanner[2].html");
if($_GET['submit'] != 1)
{
echo $content;
}
else
{
$content = $_POST['content'];
$input = $_POST["input"];
$output = "name<br/>\n";
$lines = explode("\n",$input);
if (strlen($content)===0)
die("You didn't include any keywords!");
if (strlen($input)===0)
die("You didn't include any text to search!");
$lex = explode("\n",$content); // keywords are separated by newlines
foreach($lines as $line)
{
$words = explode(" ",$line);
for($i=0;$i<count($words);$i++)
{
if (array_search($words[$i],$lex)!==false)
{
$output .= $words[$i] . " ";
}
}
$output .= "<br/>\n";
}
echo "Your output is:<br/>$output<br/><a href='scanner[2].php'>Again?</a>";
}
This is still kind of an odd way to do it. The following uses a regular expression function to remove the word and its trailing space (if it has one):
<?php
$input = "I want to remove the names tom dick bob harry";
$content = "tom dick harry";
$keywords = explode(" ",$content);
foreach ($keywords as $keyword)
{
$input = preg_replace("/".$keyword." ?/","",$input);
}
echo $input;
Output:
I want to remove the names bob
The out-of-memory condition is due to the typo you have in the for loop, i<$lexcount is always evaluated as true, so the string grows until it fills all available memory.