Wrote this to replace the outdated/ugly parsers that I've found
http://paste.ee/p/mootl (Syntax Highlighted)
http://paste.ee/r/mootl (Raw text)
Examples:
PHP Code:
$reader = new KVReader();
//Reading
print_r($reader->read('"Test" {
"key" "value"
}'));
print_r($reader->readFile("filename"));
print_r($reader->readFile("url"));
//Writing
$arr = array(
'Test' => array(
'key' => 'value'
)
);
echo $reader->write($arr);
$reader->writeFile('filename', $arr);
Credits of course to
KawMAN's
Post for the reader, adapted to use references instead of class specific values, and to the Sourcebans KVReader author for the basics used to write arrays, adapted to write to a string instead of a file, and cleaned up.