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:10
Avg. Score:4.1 ± 1.0
Reproduced:10 of 10 (100.0%)
Same Version:2 (20.0%)
Same OS:2 (20.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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2019 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 05:01:27 2019 UTC