function drupal_explode_tags

cis7 drupal_explode_tags($tags)
cle7 drupal_explode_tags($tags)
elmsmedia7 drupal_explode_tags($tags)
icor7 drupal_explode_tags($tags)
meedjum_blog7 drupal_explode_tags($tags)
mooc7 drupal_explode_tags($tags)

Explodes a string of tags into an array.

See also


23 calls to drupal_explode_tags()
comment_unpublish_by_keyword_action_submit in modules/comment/comment.module
Process comment_unpublish_by_keyword_action_form form submissions.
data_taxonomy_save_tags in sites/all/modules/local_contrib/data/data_taxonomy/data_taxonomy.module
Explode terms from typed input, create new terms.
entityreference_autocomplete_callback_get_matches in sites/all/modules/ulmus/entityreference/entityreference.module
Return JSON based on given field, instance and string.
masquerade_admin_settings_validate in sites/all/modules/ulmus/masquerade/masquerade.module
masquerade_autocomplete_multiple in sites/all/modules/ulmus/masquerade/masquerade.module
Returns JS array for Masquerade autocomplete fields.

... See full list


includes/, line 7408
Common functions that many Drupal modules will need to reference.


function drupal_explode_tags($tags) {
  // This regexp allows the following types of user input:
  // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
  $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
  preg_match_all($regexp, $tags, $matches);
  $typed_tags = array_unique($matches[1]);

  $tags = array();
  foreach ($typed_tags as $tag) {
    // If a user has escaped a term (to demonstrate that it is a group,
    // or includes a comma or quote character), we remove the escape
    // formatting so to save the term into the database as the user intends.
    $tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag)));
    if ($tag != "") {
      $tags[] = $tag;

  return $tags;