Same name and namespace in other branches
- 4.7.x includes/common.inc \drupal_attributes()
- 5.x includes/common.inc \drupal_attributes()
- 6.x includes/common.inc \drupal_attributes()
- 7.x includes/common.inc \drupal_attributes()
Format an attribute string to insert in a tag.
Parameters
$attributes: An associative array of HTML attributes.
Return value
An HTML string ready for insertion in a tag.
Related topics
13 calls to drupal_attributes()
- drupal_add_link in includes/
common.inc - Add a <link> tag to the page's HEAD.
- form in includes/
common.inc - Generate a form from a set of form elements.
- format_rss_item in includes/
common.inc - Format a single RSS item.
- form_button in includes/
common.inc - Format an action button.
- form_checkbox in includes/
common.inc - Format a checkbox.
File
- includes/
common.inc, line 1528 - Common functions that many Drupal modules will need to reference.
Code
function drupal_attributes($attributes = array()) {
if ($attributes) {
$t = array();
foreach ($attributes as $key => $value) {
$t[] = $key . '="' . check_plain($value) . '"';
}
return ' ' . implode($t, ' ');
}
}