[Reply] HI Jeremy, Sorry but I mised one line out... see below
At 09:27 on 23/04/2007 you wrote To : [EMAIL PROTECTED],[email protected] CC : [email protected], From: Gary T. Benner, [EMAIL PROTECTED] Content Type: text/html: text/html Attached: [Reply] HI Jeremy, // read in the ini file $config = parse_ini_file('config.ini', true); // print it out out just to check print_r($config); // alter whatever $config['Settings']['database']='Firebird'; // write the file back out ... see function below .. check the pathing if necessary write_ini_file('config.ini', $config); function write_ini_file($path, $assoc_array) { foreach ($assoc_array as $key => $item) { if (is_array($item)) { $content .= "\n[$key]\n"; foreach ($item as $key2 => $item2) { $content .= "$key2 = \"$item2\"\n"; } } else { $content .= "$key = \"$item\"\n"; } } if (!$handle = fopen($path, 'w')) { return false; } if (!fwrite($handle, $content)) { return false; } fclose($handle); return true; } ?> cheers Gary At 08:31 on 23/04/2007 you wrote >To : [email protected] >CC : >From: Jeremy Coulter, [EMAIL PROTECTED] >Content Type: text/html >Attached: > >This is a multi-part message in MIME format. > > > > >Hi all. I am trying to potentually solve a problem using PHP. >I need to edit a .conf file which is in the format of an INI File. > >I see PHP has this "parse_ini_file()" but the docs are a bit unclear about >certains things like writing back to the file. > >I have seen some examples, but they are only for what seems like single >section ini files, where as the one I want to alter have different section >names but the value names are all the same. > >in Delphi I would go "WriteString('MySection','MyVal','Value')" > >If there is anyone with PHP knowledge who can help, it woudl be appreciated. >The other idea I have is to use Lazarus to write a small CGI app to do it >for me. > >Jeremy > >-- >Internal Virus Database is out-of-date. >Checked by AVG Free Edition. >Version: 7.5.446 / Virus Database: 269.0.0/751 - Release Date: 07/04/2007 >22:57 > > > >_______________________________________________ >NZ Borland Developers Group Offtopic mailing list >Post: [email protected] >Admin: http://delphi.org.nz/mailman/listinfo/offtopic >Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe Gary Benner e-Engineer, Lecturer, and Software Developer Gary Benner & Associates 123 Internet Limited Waiariki Institute of Technology Mob: 021 966 992 Skype: garybenner Email: [EMAIL PROTECTED] Ref#: 41006 Ref#: 41006
_______________________________________________ NZ Borland Developers Group Offtopic mailing list Post: [email protected] Admin: http://delphi.org.nz/mailman/listinfo/offtopic Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe
