php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51982 Unexpected TC_SECTION with parse_ini_file/string
Submitted: 2010-06-02 22:58 UTC Modified: 2010-12-01 15:35 UTC
Votes:12
Avg. Score:3.9 ± 1.0
Reproduced:12 of 12 (100.0%)
Same Version:3 (25.0%)
Same OS:3 (25.0%)
From: uramihsayibok at gmail dot com Assigned:
Status: Open Package: PHP options/info functions
PHP Version: * OS: Win 7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: uramihsayibok at gmail dot com
New email:
PHP Version: OS:

 

 [2010-06-02 22:58 UTC] uramihsayibok at gmail dot com
Description:
------------
parse_ini_file and parse_ini_string can't handle arrays with multiple dimensions.

Test script:
---------------
<?php

$ini = <<<INI
a[b] = "c"
d[e][f] = "g" ; line 2
INI;

var_dump(parse_ini_string($ini));

?>

Expected result:
----------------
An appropriate var_dump

Actual result:
--------------
PHP Warning: syntax error, unexpected TC_SECTION, expecting '=' in Unknown on line 2

(or the INI filename instead of "Unknown" when using parse_ini_file)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-28 19:04 UTC] felipe@php.net
-Type: Bug +Type: Feature/Change Request -PHP Version: 5.3.2 +PHP Version: *
 [2010-12-01 15:35 UTC] jani@php.net
-Package: Filesystem function related +Package: PHP options/info functions
 [2012-02-27 11:55 UTC] info at maartendeboer dot net
I recommend implementing this the Zend Framework way using '.' as separator for multi dimension "arrays".

[section]
foo.bar[] = "a"

would then result in:

section
 - foo
  - bar
   - 0 = "a"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 19:01:27 2024 UTC