• PHP Video Tutorials

PHP - Function parse_ini_file()



The parse_ini_file() function can parse a configuration (ini) file, and it returns the settings in an array.

Syntax

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

This function can load in the ini file specified in a filename and returns the settings in an associative array. The structure of an ini file is the same as the php.ini's.

Example-1

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

Output

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

Example-2

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

Output

Array
(
    [names] => Array
        (
            [me] => Adithya
            [you] => Jai
        )

    [urls] => Array
        (
            [first] => http://www.tutorialspoint.com
            [second] => https://www.google.com
        )
		
)
php_function_reference.htm
Advertisements