1

For example I tried so:

parse_ini_string('
    abc[] =
');

but the element abc is not empty, there is 1 empty string in it

1 Answer 1

4

You can't store empty arrays in an INI file directly. The INI format is not expressive enough - the syntax above describes an array push, and as such it pushes an empty element onto the array.

A workaround, albeit ugly, is something like this:

$parsed = parse_ini_file('file.ini');

foreach ($parsed as $k => &$v) {
  if ($v === array('')) {
    $v = array();
  }
}
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.