fixing issue where merge is renumbering array keys

This commit is contained in:
dogmatic69 2012-12-07 01:26:14 +00:00
parent 00d178fa28
commit 85de93a4a7
2 changed files with 13 additions and 1 deletions

View file

@ -2163,6 +2163,18 @@ class HashTest extends CakeTestCase {
)
);
$this->assertEquals($result, $expected);
$data = array('a.b.100.a' => null, 'a.b.200.a' => null);
$expected = array(
'a' => array(
'b' => array(
100 => array('a' => null),
200 => array('a' => null)
)
)
);
$result = Hash::expand($data);
$this->assertEquals($expected, $result);
}
}

View file

@ -596,7 +596,7 @@ class Hash {
foreach ((array)$arg as $key => $val) {
if (!empty($return[$key]) && is_array($return[$key]) && is_array($val)) {
$return[$key] = self::merge($return[$key], $val);
} elseif (is_int($key)) {
} elseif (is_int($key) && isset($return[$key])) {
$return[] = $val;
} else {
$return[$key] = $val;