The parse_ini_file() function parses an ini file and returns the settings in it in an array.
PHP parse_ini_file() Function has the following syntax.
parse_ini_file(file,process_sections)
Parameter | Is Required | Description |
---|---|---|
file | Required. | ini file to check |
process_sections | Optional. | TRUE means to return is a multidimensional array with section names and settings included. Default is FALSE |
The settings are returned as an associative array on success, and FALSE on failure.
Contents of an example "test.ini" file.
[names] Developer = Bob Tester = Mike [urls] first = "http://www.java2s.com" second = "http://www.php.net"
parse_ini_file() ignores section headers and returns each .ini key and its value as an associative array.
If you pass true as the second parameter, it makes each section header an element in the return value.
<?PHP
$inifile = parse_ini_file("my.ini");
var_dump($inifile);
$inifile = parse_ini_file("my.ini", true);
var_dump($inifile);
?>