Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $default = array(
- 'a' => array(
- 'a' => 'a',
- 'b' => 'b',
- 'c' => 'c',
- ),
- );
- $user = array(
- 'b' => 1,
- 'a' => array(
- 'b' => 'something',
- 'c' => 'something else',
- 'd' => 'd',
- ),
- 'c' => 2);
- function fill_in($user, $default) {
- fill_in_aux($user, $default);
- return $default;
- }
- function fill_in_aux($user, &$default) {
- foreach ($user as $key => $value) {
- if (is_array($value)) {
- fill_in_aux($user[$key], $default[$key]);
- } else {
- $default[$key] = $value;
- }
- }
- }
- print_r(fill_in($user, $default));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement