PHP - Fonction parse_ini_file ()

La fonction parse_ini_file () peut analyser un fichier de configuration (ini), et elle renvoie les paramètres dans un tableau.

Syntaxe

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

Cette fonction peut charger dans le fichier ini spécifié dans un nom de fichier et renvoie les paramètres dans un tableau associatif. La structure d'un fichier ini est la même que celle de php.ini.

Exemple 1

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

Production

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

Exemple-2

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

Production

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

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