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:11
Avg. Score:4.0 ± 1.0
Reproduced:11 of 11 (100.0%)
Same Version:2 (18.2%)
Same OS:2 (18.2%)
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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
50 + 2 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 02:01:30 2024 UTC