1

I'm running into an error with the parse_ini_file function.

Here's the section of the file that's causing problems:

TYPE["A"]          = 1  
TYPE["B"]          = 2  
TYPE["C"]          = 3

This parses fine in PHP 5.3.1-- but it throws a PHP Warning: Error parsing in PHP 5.2.17

Is it possible to set a string as the array key in an ini file in PHP 5.2.x?

1 Answer 1

2

You can set the second parameter of parse_ini_file to true to get multidimensional array.

Your ini file:

[type]
A = 1
B = 2
C = 3

You PHP:

$arr = parse_ini_file('my_ini_file', true);

Result:

Array
(
    [type] => Array
        (
            [A] => 1
            [B] => 2
            [C] => 3
        )

)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.