使用php删除文本文件中包含字符串的行
preg_replace('/\n?.SOMETEXT.$/m','.$theData);它正在工作 现在,如何在php中使用$aDoor字符串使用使用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
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);