0

I have created my own custom config.ini file and I want to have set of configuration inside in it and user can add new ini configuration with existing one and they may delete particular configuration from ini file.

[section_one] test = abc

[section_two] and_so=on

............. etc. Currently I can parse the ini configuration using parse_ini_file() function and get array format. I need to update existing configuration on user request. If any one have any idea please post.

Thanks in advance, Sanjoy

PHPArtist
  • 61
  • 1
  • 2
  • 10

1 Answers1

0

you can do in this way . A sample

// Pass the array to update

function update_config($myConfig) {
  $myConfig = json_encode($myConfig);
  $fp = fopen('my_config.ini', 'a');
  fwrite($fp, $myConfig);
  return 'success';
}

// update config when you need

$myConfig = array();
$myConfig['section_1'] = "a";
$myConfig['section_2'] = "b";
$myConfig['section_3'] = "c";
echo update_config($myConfig)
Dino Babu
  • 5,814
  • 3
  • 24
  • 33