Home » Configuration » Config » Bug #10010
numeric index lost when parsing subarrays
Details
| Submitted | 2007-02-02 11:33 UTC |
|---|---|
| From | werner at seagullproject dot org |
| Assigned | aashley |
| Status | Closed |
| Package | Config |
| PHP Version | 5.1.2 |
| OS | linux |
| Roadmaps | 1.10.10 |
Comments
[2007-02-02 11:33 UTC] werner at seagullproject dot org
Description:
------------
we have an array with subarrays (e.g. list of month names) that should be saved as a phparray file.
the numeric indexes of the month names get lost when parsing the array, instead the array begins with index 0.
Maybe the changes from http://pear.php.net/bugs/bug.php?id=3590 caused this behaviour? Commenting out the "is_numeric" clause gives me the expected result.
Test script:
---------------
$aTrans = array(
'foo' => 'bar',
'aMonths' => array(
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December',)
);
$c = new Config();
$root = & $c->parseConfig($aTrans, 'phparray');
$filename = './test.php';
$result = $c->writeConfig($filename, 'phparray', array('name' => 'words'));
include($filename);
print_r($words)
Expected result:
----------------
save file like
$words['aMonths'][1] = 'January';
$words['aMonths'][2] = 'February';
Actual result:
--------------
file is saved like:
$words['aMonths'][0] = 'January';
$words['aMonths'][1] = 'February';