asd.ini
[first]
foo = "bar"
asd = "fgh"
number = 1
[second]
herp = "derp"
lol = "wut"
ini.php
<?php
$conf = parse_ini_file("asd.ini", true);
write_ini_file($conf, "test.ini", true);
function write_ini_file($conf, $file, $sections=false)
{
$fd = fopen($file, "w");
if($fd !== false) {
foreach($conf as $name => $content) {
if($sections===true) {
fwrite($fd, "[".$name."]\n");
foreach($content as $var => $value) {
fwrite($fd, $var ." = ". $value . "\n");
}
} else {
fwrite($fd, $name ." = ".$content ."\n");
}
}
fclose($fd);
return true;
}
return false;
}
?>