开发者

writing a structured ini file from scratch via PhP

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 alre开发者_开发问答ady.

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?


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";
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜