-3

有人知道如何在 ini 文件中找到一行并使用 php 擦除吗?

fopen等..?

4

2 回答 2

0

用这个 :

$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);
于 2013-07-13T01:22:40.820 回答
0

PHP 具有parse_ini_file非常适合读取但不适合写入的功能。看看http://pear.php.net/package/Config_Lite吗?这应该使您的任务变得简单。

于 2013-07-13T01:24:00.317 回答