Nested arrays in ini file

前端 未结 4 691
小鲜肉
小鲜肉 2021-01-11 13:36

I am trying to have a nested array structure inside an ini settings file. The structure i have is:

stuct1[123][a] = \"1\"
stuct1[123][b] = \"2\"
stuct1[123][         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-11 14:43

    You can use the sections feature of parse_ini_file for this task.

    Be sure to set your second parameter to true:

    parse_ini_file("sample.ini", true);
    

    It's not exactly possible to make sub sections but you can make an indexed sub array like this:

    [123]
    setting[] = "1"
    setting[] = "2"
    setting[] = "3"
    setting[] = "4"
    

    Parsed it would look similar like thos

    [123][setting][0] => "1"
    [123][setting][1] => "2"
    [123][setting][2] => "3"
    [123][setting][3] => "4"
    

提交回复
热议问题