有人知道如何在 ini 文件中找到一行并使用 php 擦除吗?
fopen等..?
用这个 :
$content = '';
// iterate over each line of the ini file
foreach(file('your.ini') as $line) {
// if the line doesn't start with YOURKEY ...
if(!preg_match('~^YOURKEY~', $str)) {
// add it to output
$content .= $line;
}
}
file_put_contents('your.ini', $content);
PHP 具有parse_ini_file
非常适合读取但不适合写入的功能。看看http://pear.php.net/package/Config_Lite吗?这应该使您的任务变得简单。