Skip navigation
Help

drupal_implode_tags

6 common.inc drupal_implode_tags($tags)
7 common.inc drupal_implode_tags($tags)

Implode an array of tags into a string.

See also

drupal_explode_tags()

5 calls to drupal_implode_tags()

File

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

Code

function drupal_implode_tags($tags) {
  $encoded_tags = array();
  foreach ($tags as $tag) {
    // Commas and quotes in tag names are special cases, so encode them.
    if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
      $tag = '"' . str_replace('"', '""', $tag) . '"';
    }

    $encoded_tags[] = $tag;
  }
  return implode(', ', $encoded_tags);
}