4.6.x common.inc drupal_attributes($attributes = array())
4.7.x common.inc drupal_attributes($attributes = array())
5.x common.inc drupal_attributes($attributes = array())
6.x common.inc drupal_attributes($attributes = array())
7.x common.inc drupal_attributes(array $attributes = array())

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.

... See full list

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, ' ');
  }
}