parse_ini

array parse_ini (string initext [, bool changecase [, bool convertwords]])

Parses the initext string (which is usually read from an initialization file) and returns a multidimensional associative array with section names and entry values. To generate an INI string from an array, use generate_ini().

Differences from parse_ini_file()

This function is similar to parse_ini_file(). Since the implementation of INI files in PHP is not the same as in Windows, however, parse_ini() has the following differences:

Example

An example of a valid initext is below:

; Comments should start with ';'

[AppSettings] ; Comments are allowed after a section name
ShowWindow = true
Icon = 2 4
SiteURL = "http://www.hypervisual.com/winbinder"
forum = http://www.hypervisual.com/winbinder/forum
yes = true

[FILES] ; Entries with no identifiers are valid too
"main.ico"
"second#.ico"
OtherFiles = off
third.ico

Calling parse_ini() using the example above and the default parameters will return the following array:

Array
(
    [Appsettings] => Array
        (
            [showwindow] => 1
            [icon] => 2 4
            [siteurl] => http://www.hypervisual.com/winbinder
            [forum] => http://www.hypervisual.com/winbinder/forum
            [yes] => 1
        )
 
    [Files] => Array
        (
            [0] => main.ico
            [1] => second#.ico
            [otherfiles] => 0
            [2] => third.ico
        )
)


See also

generate_ini
Auxiliary functions