Php 如何根据数据库中的更新在INI文件中写入一些字符串值

Php 如何根据数据库中的更新在INI文件中写入一些字符串值,php,arrays,codeigniter,str-replace,Php,Arrays,Codeigniter,Str Replace,简而言之,我有一个用户,他有多个INI文件上传到他的帐户。 路径和文件名存储在数据库中 因此INI文件有部分,然后是参数和值 这是我的INI文件示例: [INIDetails] SipUserName= Password= Domain=182.010.50.59 Proxy=5080 Port= SipAuthName= DisplayName= ServerMode=Automatic UCServer=192.168.50.5250 UCUserName= UCPassword= [Di

简而言之,我有一个用户,他有多个INI文件上传到他的帐户。
路径
文件名
存储在数据库中

因此INI文件有部分,然后是参数和值

这是我的INI文件示例:

[INIDetails]
SipUserName=
Password=
Domain=182.010.50.59
Proxy=5080
Port=
SipAuthName=
DisplayName=
ServerMode=Automatic
UCServer=192.168.50.5250
UCUserName=
UCPassword=

[DialPlan]
DP_Exception=
DP_Rule1=
DP_Rule2=

[Advanced]
OperationMode=1
MutePkey=16
Codec=
PTime=20
AudioMode=3
SoftwareAEC=
EchoTailLength=5
PlaybackBuffer=10
CaptureBuffer=10
JBPrefetchDelay=60
JBMaxDelay=160
SipToS=
RTPToS=00
LogLevel=
现在,对于域和代理之类的值,我将它们存储在数据库中,让用户编辑这些值

现在问题来了:

如果数据库值中有更新,我将遍历并获取用户拥有的所有文件,并希望更新它们。所以我这样做:

function update_ini($site_session)
{
    $base_configs= $this->upload_ini_m->get_files();
    //Now Here We Have Files That Has to be updated as per DATABASE PARAMS
    $count = count($base_configs);
    //WE KNOW THE NUMBER OF FILES TO UPDATED

    for ($i=0; $i < $count; $i++) 
    { 
      $filename = $base_configs[$i]->base_ini_filename;
      $path = $base_configs[$i]->file_path;

      //Here We Get Final File To Process//
      $file_to_update =$path.$filename;

     // $file_contents = file_get_contents( $file_to_update);        

      //Parse the INI     
      $file_contents = $this->data['parameters']  = parse_ini_file($file_to_update,true);


      //This is Our Array which has the values so replace the values here.

        foreach ($file_contents as $key => $sections) 
        {
          foreach ($sections as $parameter => $value) 
          {
            //Update files here

          }


        }

    }
}
 array (size=3)
  'INIDetails' => 
    array (size=11)
      'SipUserName' => string '' (length=0)
      'Password' => string '' (length=0)
      'Domain' => string '182.010.50.59' (length=13)
      'Proxy' => string '5080' (length=4)
      'Port' => string '' (length=0)
      'SipAuthName' => string '' (length=0)
      'DisplayName' => string '' (length=0)
      'ServerMode' => string 'Automatic' (length=9)
      'UCServer' => string '192.168.50.5250' (length=15)
      'UCUserName' => string '' (length=0)
      'UCPassword' => string '' (length=0)
  'DialPlan' => 
    array (size=3)
      'DP_Exception' => string '' (length=0)
      'DP_Rule1' => string '' (length=0)
      'DP_Rule2' => string '' (length=0)
  'Advanced' => 
    array (size=14)
      'OperationMode' => string '1' (length=1)
      'MutePkey' => string '16' (length=2)
      'Codec' => string '' (length=0)
      'PTime' => string '20' (length=2)
      'AudioMode' => string '3' (length=1)
      'SoftwareAEC' => string '' (length=0)
      'EchoTailLength' => string '5' (length=1)
      'PlaybackBuffer' => string '10' (length=2)
      'CaptureBuffer' => string '10' (length=2)
      'JBPrefetchDelay' => string '60' (length=2)
      'JBMaxDelay' => string '160' (length=3)
      'SipToS' => string '' (length=0)
      'RTPToS' => string '00' (length=2)
      'LogLevel' => string '' (length=0