PHP parse_ini_file() Function

Definition

The parse_ini_file() function parses an ini file and returns the settings in it in an array.

Syntax

PHP parse_ini_file() Function has the following syntax.

parse_ini_file(file,process_sections)

Parameter

ParameterIs RequiredDescription
fileRequired.ini file to check
process_sectionsOptional.TRUE means to return is a multidimensional array with section names and settings included. Default is FALSE

Return

The settings are returned as an associative array on success, and FALSE on failure.

Format of init file

Contents of an example "test.ini" file.


[names]//from  w w  w  .ja v  a 2 s . c  om
Developer = Bob
Tester = Mike
[urls]
first = "http://www.java2s.com"
second = "http://www.php.net"

Example

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//from  w  ww.jav a2  s .c o m
      $inifile = parse_ini_file("my.ini");
      var_dump($inifile);
      $inifile = parse_ini_file("my.ini", true);
      var_dump($inifile);
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions