function taxonomy_terms_parse_string

6.x taxonomy.module 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.

1 call to taxonomy_terms_parse_string()
taxonomy_term_page in drupal-6.x/modules/taxonomy/taxonomy.pages.inc
Menu callback; displays all nodes associated with a term.

File

drupal-6.x/modules/taxonomy/taxonomy.module, line 1312
Enables the organization of content into categories.

Code

function taxonomy_terms_parse_string($str_tids) {
  $terms = array('operator' => '', 'tids' => 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;
}