<form method="post" action="">
Дума/Изречение - <input type="text" name="string" /><input type="submit" name="submit" value="Изтрий"/></form>
<?
if (isset($_POST['submit']))
{
$string=$_POST['string'];
if (empty($string))
{
echo "Празно поле !";
}
else
{
$file="file.txt";
if (!file_exists($file))
{
echo "Файла не съществува !";
}
else
{
$op=file_get_contents($file);
$search=preg_match("/$string/", $op);
if (!$search)
{
echo "Не съществува тази дума/стринг !";
}
else
{
$replace=str_replace("$string", "", $op);
$new=file_put_contents($file, $replace);
if ($new)
{
echo "Успешно редактирахте файла !";
}
else
{
echo "Възникна някаква грешка !";
}
}
}
}
}
?>