Forum Moderators: coopster

Message Too Old, No Replies

writing an ini file from array

php ini generating

         

belfasttim

2:14 am on Sep 22, 2009 (gmt 0)

10+ Year Member



Hi-- I'm building an app that has long configuration files-- long lists of DB columns that map to columns grabbed from a data feed.

I'm currently writing these out to ini files. However, I'm not quite clear if it's possible to write an ini file that's equivalent to an array more than 2 levels deep.

Is there any php function that does the reverse of the parse_ini_file function, taking an array and turning it into an ini file?

I was also considering serializing these arrays and putting them in a DB-- are there any pros and cons to these approaches?

Thanks!

coopster

11:15 am on Sep 22, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



However, I'm not quite clear if it's possible to write an ini file that's equivalent to an array more than 2 levels deep.

Not with the existing ini functions. You would likely need to roll your own code to build any deeper.

reverse of the parse_ini_file function

No, not built-in anyway. Again, you would likely need to write your own.

serializing

Always an option. But it may be just as simple to map the column names in the database table rather than serialize them and store them.

belfasttim

5:25 pm on Sep 22, 2009 (gmt 0)

10+ Year Member



Thanks as always Coopster.

Could you explain a little more what you mean by map the column names in the database table?

Thanks