English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP parse_ini_file() Function Usage and Example

PHP Filesystem Reference Manual

The parse_ini_file() function can parse configuration (ini) files and return the settings in array form.

Syntax

array parse_ini_file ( string $filename [, bool $process_sections = FALSE [, int $scanner_mode = INI_SCANNER_NORMAL ]] )

This function can load the ini file specified in the filename and return the settings in the form of an associative array. The structure of the ini file is the same as that of php.ini.

Example1

<?php
   print_r(parse_ini_file("/PhpProject/simple.ini"));
?>

Output Result

Array
(
    [me] => Adithya
    [you] => Jai
    [first] => http://www.oldtoolbag.com
    [second] => https://www.google.com
)

Example2

<?php
   print_r(parse_ini_file("/PhpProject/simple.ini", true));
?>

Output Result

Array
(
    [names] => Array
        (
            [me] => Adithya
            [you] => Jai
        )
    [urls] => Array
        (
            [first] => http://www.oldtoolbag.com
            [second] => https://www.google.com
        )
)
PHP Filesystem Reference Manual