Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Created July 27, 2013 11:58
Show Gist options
  • Save wpscholar/6094670 to your computer and use it in GitHub Desktop.
Save wpscholar/6094670 to your computer and use it in GitHub Desktop.
Convert an associative array of attributes to a string suitable for use in HTML.
<?php
function get_attribute_string(array $atts ) {
foreach( $atts as $key => &$value ) {
$value = "{$key}=\"{$value}\"";
}
return join( ' ' , $atts );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment