从 .ini 文件解析多维数组

Parse a multidimensional array from .ini file

我想知道是否有(在 .ini 文件中)实现某些东西,当 parse_ini_file()(在 php 中)解析时会创建一个多维数组,而不仅仅是一个关联数组数组?

我一直在搜索,但一无所获,所以我想知道这里是否有人知道是否允许这样的事情。

示例:

file.ini(半 sudo 代码):

input = input1 = ('Hello world this is test #1')
input = input2 = ('Hello world this is test #2')

code.php:

$array = parse_ini_file("file.ini", true);
print_r($array);

预期输出:

Array
(
    [input] => Array
        (
            [input1] => Hello world this is test #1
            [input2] => Hello world this is test #2
        )

)

在想出更好的方式来表达我的问题后,我似乎找到了自己的答案。

.ini 文件可以包含用方括号 ([]) 括起来的部分,例如:

[input]
  input1 = ('Hello world this is test #1');
  input2 = ('Hello world this is test #2');

这正是我要找的部分(在解析时)将其转换为多维数组:

Array
(
    [input] => Array
        (
            [input1] => Hello world this is test #1
            [input2] => Hello world this is test #2
        )

)

在发布这个问题之前绝对应该再等一段时间并进行更多研究,但我会把它留给可能遇到与我最初遇到的问题相同的其他人。