Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php删除文本文件中包含字符串的行_Php - Fatal编程技术网

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

使用php删除文本文件中包含字符串的行,php,Php,preg_replace('/\n?.SOMETEXT.$/m','.$theData);它正在工作 现在,如何在php中使用$aDoor字符串使用unset()函数 范例 <?php $myFile = "myfile.txt"; $fh = fopen($myFile, 'rt'); $theData = fread($fh, filesize($myFile)); $aDoor = $_GET['idno']; echo $aDoor; $theData = preg_replace

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

现在,如何在php中使用$aDoor字符串使用
unset()
函数

范例

<?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;
?>

然后写入内容…

no$ador是从以前的php文件preg\u replace('/\n?*SOMETEXT.$/m','.$theData)获取的字符串;它现在正在研究如何使用$ADO或stringpreg_替换('/\n?.SOMETEXT.$/m','.$theData);现在正在研究如何使用$ADOR string如何在preg_replace$string='April 15,2003'中使用var string$模式='/(\w+)(\d+)(\d+)/i'$替换=“${1}1,$3”;echo preg_replace($pattern,$replacement,$string);这是pre_replace()的一个示例
 unset($aDoor);