使用php删除包含文本文件中的字符串的行

时间:2013-01-16 11:27:47

标签: php

<?php
$myFile = "myfile.txt";
$fh = fopen($myFile, 'rt');
$theData = fread($fh, filesize($myFile));
$aDoor = $_GET['idno'];
echo $aDoor;
$theData = preg_replace('/\n?.*$aDoor.*$/m', '', $theData);

fwrite($fh, $theData);
fclose($fh);
echo $theData;
?>

preg_replace('/ \ n?。 SOMETEXT。 $ / m','',$ theData);它正在运作

现在如何使用$ aDoor字符串

1 个答案:

答案 0 :(得分:0)

在php中使用unset()函数

实施例

 unset($aDoor);

然后写内容......