Parses an ini file.
This function parses an ini file and returns the result as an associative array. If the optional use_sections is set to true, the array returned will be two-dimensional with the section name as the first key. Directive names in the ini file are followed by an equal sign and then the value. A semicolon starts a comment.
<!--
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Sample ini file for parse_ini_file.php
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[db settings]
server = sqlhost
user = www
passwd = qwerty
[user]
self_register = yes
show_email = no
show_realname = yes
-->
<?php
$config = parse_ini_file("sample.ini", TRUE);
print "<pre>";
print_r($config);
print "</pre>";
?> Array
(
[db settings] => Array
(
[server] => sqlhost
[user] => www
[passwd] => qwerty
)
[user] => Array
(
[self_register] => 1
[show_email] =>
[show_realname] => 1
)
)
This example shows the result of using parse_ini_file() with use_sections set to TRUE.