rendered paste body<?php if (isset($_GET['search']) && !empty($_GET['search'])) { $txtfile = 'file.txt'; $cnt = 0; // line counter $limit = 100; // limit output $retArr = array(); $sPhrases = explode(' ',$_GET['search']); $sPhrases = array_unique($sPhrases); if ($fp = fopen($txtfile,'r')) { while (!feof($fp)) { $cnt++; $baz = fgets($fp,4096); $match = false; foreach ($sPhrases as $_word) { if (empty($_word)) continue; } if ($match) { $retArr[$cnt] = $baz; } } } if (count($retArr)) { echo "Found {$_GET['search']} in the following lines:<br />"; foreach ($retArr as $_line => $_txt) { echo "<a href='$_txt' target='_blank'>$_txt</a><br />"; } } else { echo "No occurence of {$_GET['search']} was found"; } }?>