parse_ini_string() function in PHP


The parse_ini_string() function parses a configuration string. The function returns the settings as an associative array on success. It returns FALSE on failure.

Syntax

parse_ini_string(file_path, process_sections)

Parameters

  • file_path − The ini file to be parsed.

  • process_sections − If set to TRUE, you will get a multidimensional array with section names and settings included.

Return

The parse_ini_string() function returns the settings as an associative array on success. It returns FALSE on failure.

Let’s say the content of our “demo.ini” is −

[names]
one = Anne
[urls]
host1 = "https://www.example1.com"

Example

<?php
   print_r(parse_ini_string("demo.ini"));
?>

Output

Array
(
[one] => Anne

[host1] => https://www.example1.com
)

Updated on: 24-Jun-2020

81 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements