drupal_attributes
- Versions
- 4.6 – 6
drupal_attributes($attributes = array())- 7
drupal_attributes(array $attributes = array())
Format an attribute string to insert in a tag.
Each array key and its value will be formatted into an HTML attribute string. If a value is itself an array, then each array element is concatenated with a space between each value (e.g. a multi-value class attribute).
Parameters
$attributes An associative array of HTML attributes.
Return value
An HTML string ready for insertion in a tag.
Code
includes/common.inc, line 2637
<?php
function drupal_attributes(array $attributes = array()) {
foreach ($attributes as $attribute => &$data) {
if (is_array($data)) {
$data = implode(' ', $data);
}
$data = $attribute . '="' . check_plain($data) . '"';
}
return $attributes ? ' ' . implode(' ', $attributes) : '';
}
?>Login or register to post comments 