有人知道我如何在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?这会让你的任务变得简单。