Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaysn/1185752 to your computer and use it in GitHub Desktop.
Save jaysn/1185752 to your computer and use it in GitHub Desktop.
returns a standartized array following the scheme of $defaul_pairs(accepted_field => default_value) inserting the values of $atts if the field exists in $default_pairs
function att_array_combine($default_pairs, $atts) {
$atts = (array)$atts;
$combined = array();
foreach($default_pairs as $name => $default) {
if ( array_key_exists($name, $atts) )
$combined[$name] = $atts[$name];
else
$combined[$name] = $default;
}
return $combined;
}
function att_array_combine($default_pairs, $atts) {
$atts = (array)$atts;
$combined = array();
foreach($default_pairs as $name => $default) {
if ( array_key_exists($name, $atts) )
$combined[$name] = $atts[$name];
else
$combined[$name] = $default;
}
return $combined;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment