Skip to content

Instantly share code, notes, and snippets.

@peterwang
Created July 14, 2013 19:28
Show Gist options
  • Save peterwang/5995503 to your computer and use it in GitHub Desktop.
Save peterwang/5995503 to your computer and use it in GitHub Desktop.
<?php
// cascading configurations via
// merging with defaults options
$defaults = array(
'foo' => 'bar',
'baz' => 'qux',
'quux' => 'fred',
);
$option1 = array(
'foo' => 'abc',
'abc' => 'def',
);
$option2 = array(
'baz' => 'xyz',
'abc' => '123',
);
$options = array_merge($defaults, $option1, $option2);
print_r($options);
/*
Array
(
[foo] => abc
[baz] => xyz
[quux] => fred
[abc] => 123
)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment