parse_ini_str ()

function parse_ini_str ($Str, $ProcessSections = TRUE)

While PHP already provides a simple way to read an INI file using parse_ini_file () function, it doesn't have a way to read INI from a variable.

$Str = the string containing INI configuration.

$ProcessSections = set to TRUE to get a multidimensional array, with the section names and settings included.

This function is required by qE's module management.

It returns an array of configuration.

Example 1

<?php
require './includes/user_init.php';

// taken from PHP documentation
$ini_var = "; This is a sample configuration file
; Comments start with ';', as in php.ini

[first_section]
one = 1
five = 5
animal = BIRD

[second_section]
path = \"/usr/local/bin\"
URL = \"http://www.example.com/~username\"";

// Parse without sections
print_r (parse_ini_str ($ini_var, false));

// Parse with sections
print_r (parse_ini_str ($ini_var, false));
?>

Sample Output

Array
(
[one] => 1
[five] => 5
[animal] => BIRD
[path] => /usr/local/bin
[URL] => http://www.example.com/~username
)
Array
(
[one] => 1
[five] => 5
[animal] => BIRD
[path] => /usr/local/bin
[URL] => http://www.example.com/~username
)

Notice that unlike PHP's parse_ini_file (), this function doesn't return contants.


: @ 07:00am
Last Updated: @ 07:00am

There is no comment. Why not be the first?

More Comments/Post Your Own

Advertisement

Online Users

There are 5 users online.

Connect

Connect with us on Facebook

Newsletter

Subscribe to our newsletter for the latest updates and exciting promotions!