PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Configuration » Config » Bug #10010

numeric index lost when parsing subarrays

Details

Submitted2007-02-02 11:33 UTC
Fromwerner at seagullproject dot org
Assignedaashley
StatusClosed
PackageConfig
PHP Version5.1.2
OSlinux
Roadmaps1.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';