function biblio_explode_keywords in Bibliography Module 6
Same name and namespace in other branches
- 6.2 includes/biblio.keywords.inc \biblio_explode_keywords()
- 7 includes/biblio.keywords.inc \biblio_explode_keywords()
- 7.2 includes/biblio.keywords.inc \biblio_explode_keywords()
3 calls to biblio_explode_keywords()
- biblio_form_validate in ./biblio.module
- Implementation of hook_validate().
- biblio_insert_keywords in ./biblio.keywords.inc
- _biblio_keyword_links in ./biblio.pages.inc
File
- ./biblio.keywords.inc, line 263
Code
function biblio_explode_keywords($string, $sep = NULL) {
if (!$sep) {
$sep = check_plain(variable_get('biblio_keyword_sep', ','));
}
$regexp = '%(?:^|' . $sep . '\\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^"' . $sep . ']*))%x';
preg_match_all($regexp, $string, $matches);
$keyword_array = array_unique($matches[1]);
$keywords = array();
foreach ($keyword_array as $keyword) {
$keyword = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\\1', $keyword)));
if ($keyword != "") {
$keywords[] = $keyword;
}
}
return $keywords;
}