Jump to content

modfing ini files


ratcateme

Recommended Posts

don't worry i wrote my own function

<?php
function update_ini($name, $new_value, $ini_file){
$found=true;
$file=parse_ini_file($ini_file);
foreach($file as $key => &$value){
	$value=explode('=',$value);
	if($key==$name){
		$value[0]=$new_value;
		$found=false;
	}
	$new_file.=$key.'='.$value[0]."\n";
}
if($found){
	$new_file.=$name.'='.$new_value."\n";
}
$ini=fopen($ini_file,'w');
fwrite($ini,$new_file);
fclose($ini);
}
?>

Beware it dose not pay attention to sections.

 

Scott.

 

Link to comment
https://forums.phpfreaks.com/topic/89035-modfing-ini-files/#findComment-455999
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.