function taxonomy_implode_tags
Same name in other branches
- 9 core/modules/taxonomy/taxonomy.module \taxonomy_implode_tags()
- 8.9.x core/modules/taxonomy/taxonomy.module \taxonomy_implode_tags()
Implodes a list of tags of a certain vocabulary into a string.
See also
1 call to taxonomy_implode_tags()
- taxonomy_field_widget_form in modules/
taxonomy/ taxonomy.module - Implements hook_field_widget_form().
File
-
modules/
taxonomy/ taxonomy.module, line 1416
Code
function taxonomy_implode_tags($tags, $vid = NULL) {
$typed_tags = array();
foreach ($tags as $tag) {
// Extract terms belonging to the vocabulary in question.
if (!isset($vid) || $tag->vid == $vid) {
// Make sure we have a completed loaded taxonomy term.
if (isset($tag->name)) {
// Commas and quotes in tag names are special cases, so encode 'em.
if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
$typed_tags[] = '"' . str_replace('"', '""', $tag->name) . '"';
}
else {
$typed_tags[] = $tag->name;
}
}
}
}
return implode(', ', $typed_tags);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.