function drupal_explode_tags

cis7 common.inc drupal_explode_tags($tags)
cle7 common.inc drupal_explode_tags($tags)
elmsmedia7 common.inc drupal_explode_tags($tags)
icor7 common.inc drupal_explode_tags($tags)
meedjum_blog7 common.inc drupal_explode_tags($tags)
mooc7 common.inc drupal_explode_tags($tags)

Explodes a string of tags into an array.

See also

drupal_implode_tags()

27 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.
custom_formatters_autocomplete in sites/all/modules/local_contrib/custom_formatters/plugins/export_ui/custom_formatters.inc
Field Types autocomplete callback.
custom_formatters_field_formatter_info in sites/all/modules/local_contrib/custom_formatters/includes/field.inc
Implements hook_field_formatter_info().
custom_formatters_formatter_is_active in sites/all/modules/local_contrib/custom_formatters/custom_formatters.module
custom_formatters_insert_styles in sites/all/modules/local_contrib/custom_formatters/includes/insert.inc
Implements hook_insert_styles().

... See full list

File

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

Code

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;
}