Skip to content

Instantly share code, notes, and snippets.

@johndwells
Created August 25, 2011 17:56
Show Gist options
  • Save johndwells/1171300 to your computer and use it in GitHub Desktop.
Save johndwells/1171300 to your computer and use it in GitHub Desktop.
Interset & merge an array of settings, discarding invalid keys
<?php
$default_settings = array(
'setting1' => '',
'setting2' => ''
);
// assuming $settings has been passed
// interset & merge with defaults
$settings = array_merge($default_settings, array_intersect_key($settings, $default_settings));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment