$str = isset($_GET['str']) ? $_GET['str'] : '';
if (empty($str))
{
die('Podaj str');
}
if ($fp = fopen("text.txt", "r"))
{
$ile = 0;
while(!feof($fp))
{
$line = fgets($fp);
if (strpos($line, $str) !== false)
{
$ile = 2;
print $line . "
";
continue;
}
if ($ile > 0)
{
print $line . "
";
$ile--;
}
}
fclose($fp);
}
?>