Skip to content

Commit

Permalink
Update array merge fix issue with overwriting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Macnamara committed Jul 18, 2014
1 parent 32afd76 commit d4c8cc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ public function only($keys)

$results = array();
foreach ($keys as $key) {
$results = array_merge($results, $this->_buildArray(explode('.', $key), $this->get($key)));
$results = array_merge_recursive($results, $this->_buildArray(explode('.', $key), $this->get($key)));
}

var_dump($results);
return $results;
}

Expand Down
1 change: 1 addition & 0 deletions tests/ParserPHPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function return_value_for_multi_level_key()
$this->assertEquals(array('id' => 123, 'note' => array('headers' => array('from' => '[email protected]'), 'body' => 'Hello World')), $parser->except('note.headers.to'));
$this->assertEquals(array('id' => 123, 'note' => array('headers' => array('to' => '[email protected]', 'from' => '[email protected]'))), $parser->except('note.body'));

$this->assertEquals(array('note' => array('headers' => array('to' => '[email protected]', 'from' => '[email protected]'))), $parser->only('note.headers.to', 'note.headers.from'));
$this->assertEquals(array('id' => 123, 'status' => null, 'note' => array('body' => 'Hello World')), $parser->only('note.body', 'id', 'status'));
}

Expand Down

0 comments on commit d4c8cc7

Please sign in to comment.