taxonomy_terms_parse_string
- Versions
- 5 – 6
taxonomy_terms_parse_string($str_tids)
Parses a comma or plus separated string of term IDs.
Parameters
$str_tids A string of term IDs, separated by plus or comma. comma (,) means AND plus (+) means OR
Return value
an associative array with an operator key (either 'and' or 'or') and a tid key containing an array of the term ids.
Code
modules/taxonomy/taxonomy.module, line 1376
<?php
function taxonomy_terms_parse_string($str_tids) {
$terms = array();
if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) {
$terms['operator'] = 'or';
// The '+' character in a query string may be parsed as ' '.
$terms['tids'] = preg_split('/[+ ]/', $str_tids);
}
else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str_tids)) {
$terms['operator'] = 'and';
$terms['tids'] = explode(',', $str_tids);
}
return $terms;
}
?>Login or register to post comments 