As given, the code loops through each line in the file, looks to see if that line contains the entered word and, if so, displays that line on screen, effectively creating the HTML link (because that's what each line of the file is!).
It's a really clumsy way of doing this, because
The links are hard-coded in the file, making them difficult to maintain, and
The test (strpos) will find the given word anywhere in line, so if you were to enter the value "target", it would match each and every line!
A simpler and safer way might be to hold just the words in the file, without all the HTML stuff, and search that, then create the HTML for the selected line:
. . .
$found = false;
foreach ($lines as $line)
{
if ($line === $search)
{
$found = true;
printf( '<a href="https://blabla.com/blablabla/blablablabla/%s" target="_blank" rel="noopener noreferrer">%s</a><br/>', $line, $line );
break;
}
}
// If the text was not found, show a message
if (!$found)
. . .
Regards,
Phill W.