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

16 calls to drupal_attributes()
drupal_add_link in includes/common.inc
Add a <link> tag to the page's HEAD.
format_xml_elements in includes/common.inc
Format XML elements.
l in includes/common.inc
Format an internal Drupal link.
theme_button in includes/form.inc
theme_checkbox in includes/form.inc
Format a checkbox.

... See full list

File

includes/common.inc, line 1076
Common functions that many Drupal modules will need to reference.

Code

function drupal_attributes($attributes = array()) {
  if (is_array($attributes)) {
    $t = '';
    foreach ($attributes as $key => $value) {
      $t .= " {$key}=" . '"' . check_plain($value) . '"';
    }
    return $t;
  }
}