Jump to content

Archived

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

vbnullchar

Config File Help

Recommended Posts

hi everyone,

how can i read/write a config file
heres my config file
>> config.cfg <<

[topic]
title = "sample title"

[sub-topic]
sub_title = "sample sub title"

[rate]
rate1 = 1


thanks

Share this post


Link to post
Share on other sites
You might want to look into [url=http://us2.php.net/manual/en/function.fread.php]fread[/url] and [url=http://us2.php.net/manual/en/function.fwrite.php]fwrite[/url].


Good Luck,
Tom

Share this post


Link to post
Share on other sites
hi tom, thanks for the reply. how about if i want to modify a certain value.

Share this post


Link to post
Share on other sites
this is some what complex and you may run into serveral issues. What I would do is have a table in a db with the fields that I want in my file. Then if I need to change a certain field, I would update the db then rewrite the file.

It is easier to add a new line(with out a db.) then it is to edit a line. This is because if you are going to have multipule lines within your topic = "  "; it will be very difficult to read inbetween the "" .

Were as if you just rewrote the file from a db it would only take seconds and you would know that you got it right..


Good Luck,
Tom

Share this post


Link to post
Share on other sites

×

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.