ratcateme Posted February 2, 2008 Share Posted February 2, 2008 i have a ini file which i phrase into php using parse_ini_file() i want to know if there is a function that i can use to set a ini value without rewriting the whole file. Scott. Quote Link to comment https://forums.phpfreaks.com/topic/89035-modfing-ini-files/ Share on other sites More sharing options...
ratcateme Posted February 2, 2008 Author Share Posted February 2, 2008 Sorry for the spelling *modifying Quote Link to comment https://forums.phpfreaks.com/topic/89035-modfing-ini-files/#findComment-455992 Share on other sites More sharing options...
ratcateme Posted February 2, 2008 Author Share Posted February 2, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/89035-modfing-ini-files/#findComment-455999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.