-1

I have a config.ini file, I need to read values from it and to write to it and update it.

this function "parse_ini_file" returns an associative array from the ini file, right now I'm looking into how to access the array to retrieve values.

But how do I update those values? I guess it would be possible to just store them in the returned array, but how do you save it back to the ini file?

Best Regards Joricam

Joricam
  • 2,329
  • 4
  • 18
  • 14
  • This is your fourth question about parsing ini files. It seems you don't bother testing the given advises or links. Beware that you're only a few downvotes away from a ban. http://stackoverflow.com/questions/how-to-ask – mario Apr 17 '11 at 22:06
  • possible duplicate of [Need to parse ini file to extract values](http://stackoverflow.com/questions/3764254/need-to-parse-ini-file-to-extract-values) – mario Apr 17 '11 at 22:10

1 Answers1

1

create ini file, write values in PHP

$file_array = parse_ini_file('something.ini',true);

write_ini_file($file_array ,'something2.ini',true);

I run this, my first INI has

~~~Something.ini~~~

[people]
name="hello"
where="johndaly"

and then my second INI is created and has

~~~Something2.ini~~~

[people]
name = "hello"
where = "johndaly"

I don't see the problem :P

Is it that the KEYS(Name, where) have quotes around them or is it that the VALUES ("Hello", Johndaly") have quotes around them? Because the values are SUPPOSED to have quotes, otherwise you get all sorts of strange parse errors down the road.

I used the base "write php file" code provided to read and write the array.

Community
  • 1
  • 1
Anther
  • 1,834
  • 12
  • 13
  • that what im doing but it saves the values wrong with quotes around the keys – Joricam Apr 17 '11 at 21:57
  • @Joricam I'm ... going to explain ... since.. it worked perfectly for me. You're supposed to have quotes around the Values, not the keys. Otherwise the INI will parse certain characters such as 0 and such incorrectly. – Anther Apr 17 '11 at 23:56