0

Im creating a picture viewer for a friend of mine but i am unable to use a database because his hosting doesn't allow one.

So im left trying to use ini files but i dont know how to write a structured ini file using php..i have successfully put together a script to read it via parse_ini_file() and break it down into it seperate categories and keys but i need to know how to write the acctuall structure if there isn't one already.

For example

[flowerpics]
picone = filelocation
pictwo = filelocation

[artpics]    
picone = filelocation

this is how im basing my parse_ini_file() script for ...so what if he wants to add a whole new category to this file ..lets say he wants to add "Rockandrollpics" ...how can i go about adding that into an ini file?

Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
Jon
  • 1
  • possible duplicate of [create ini file, write values in PHP](http://stackoverflow.com/questions/1268378/create-ini-file-write-values-in-php) – mario Aug 24 '11 at 19:31

2 Answers2

1

If I were you, I would consider using some standard - like JSON, YAML, or even BJSON - it's almost as simple as INI files, but gives you more control about structuring the data. Your example with JSON:

"flowerpics"
{
    "picone" : "filelocation"; 
    "pictwo" : "filelocation"; 
}

"artpics"
{
    "picone" : "filelocation";
}
Roman Pietrzak
  • 635
  • 3
  • 15
0

If you don't use Mysql you can try to use SqlLite instead of. You needn't anything except php extension sqllite. Look at http://php.net/manual/en/book.sqlite.php for more info.

Andrej
  • 7,474
  • 1
  • 19
  • 21