Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Bug #8357 Unexpected result from IniFile when comma in use
Submitted: 2006-08-04 09:14 UTC
From: teon dot ooi at gmail dot com Assigned: aashley
Status: Closed Package: Config (version 1.10.6)
PHP Version: 5.0.4 OS: Windows
Roadmaps: (Not assigned)    
Subscription  


 [2006-08-04 09:14 UTC] teon dot ooi at gmail dot com (Teon)
Description: ------------ When I try to use comma(,) inside the ini with double quote("), the value will split into arrays which I don't want to. config.ini: [meta] robots = "index, follow" keywords = "key, words" In Config/Container/IniFile.php, line 71: ... foreach ($value as $directive => $content) { if (strpos($content, '"') === false) { $values = preg_split('/\s*,\s+/', $content); ... The strpos() does not return the position of first occurrence of double quote(") since it has been removed from the parse_ini_file() when parse the file. Test script: --------------- <?php require_once('Config.php'); $config = new Config; $root =& $config->parseConfig('config.ini', 'IniFile'); $settings= $root->toArray(); var_dump($settings); ?> Expected result: ---------------- array(1) { ["root"]=> array(1) { ["meta"]=> array(2) { ["robots"]=> array(2) { [0]=> string(5) "index" [1]=> string(6) "follow" } ["keywords"]=> array(2) { [0]=> string(3) "key" [1]=> string(5) "words" } } } } Actual result: -------------- array(1) { ["root"]=> array(1) { ["meta"]=> array(2) { ["robots"]=> string(12) "index, follow" ["keywords"]=> string(9) "key, words" } } }

Comments

 [2006-08-11 01:49 UTC] aashley at php dot net (Adam Ashley)
I don't think I can fix this behaviour without completely removing the ability to split options on commas. As that behaviour is expected I don't think removing it is an option at this point. I'd suggest you switch to using the IniCommented Container which parses your sample ini file in as expected.