This is a simple class to parse INI files.
public static function fromArray( |
| ) |
Converts an associative array into an INIParser object
Read the contents of an INI file into a two-dimensional array. This method preserves comments in the file.
Serializes the INI file into a string.
The INI file structure as a string that can be written to a file.
function writeFile( |
| ) |
Write the INI file back to the disk.
file | The filename to write to. Defaults to the filename property. |
True if the write succeeds, false otherwise.
function value( |
| ) |
Get a value from the INI file.
Takes up to three parameters. If one parameter is given, then it is interpreted as a key in the current section (last section accessed). If two are given, the first is a section and the second is a key. If three, then the first is the section, the second is the key, and the third is a default value if the key is not set.
A string containing the value of the given key, or the default value.
function valueIsSet( |
| ) |
Determine if a particular key has been set.
This can take one or two parameters. If one is given, it is a key in the current section. If two, the first is a secion and the second is a key.
True if the given key has been set, false otherwise.
function setValue ( |
| ) |
Sets a value for a key.
Takes two or three parameters. If two, then the first is a key in the current section and the second is a value. If three, then the first is a section, the second a key, and the third the value.
The value to which the key was set.
function getSection( |
| ) |
Returns the given section as an array. Removes any comments from that section of the file.
sec | The section of the file to get. |
An array of the section with variables as keys and values as elements.
Gets a list of the section names available in the file.
An array of strings, each of which is the name of a section.
function merge( |
| ) |
Merge another INI file into the current one. If a key from the other file is not set, it will be set with the value from the other file. Keys that are already set will not be modified.
file | The INIParser object to merge with the current object. |