1 common.inc backdrop_implode_tags(array $tags)

Implodes an array of tags into a string.

Parameters

array $tags: Array of tags.

Return value

string:

See also

backdrop_explode_tags()

File

core/includes/common.inc, line 9088
Common functions that many Backdrop modules will need to reference.

Code

function backdrop_implode_tags(array $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);
}