Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/28/2020 in all areas

  1. 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.
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.