You are here

function lineage_get_weight in Taxonomy Lineage 6

Same name and namespace in other branches
  1. 7 lineage.module \lineage_get_weight()

Get the weight string from the beginning of a lineage term string.

Parameters

term_string one line of a lineage, with weight:

Return value

The weight from term_string, or false on failure.

File

./lineage.module, line 252

Code

function lineage_get_weight($term_string) {
  $matches = array();
  if (preg_match("([0-9]+-)", $term_string, $matches)) {

    // Return the matched weight pattern, minus the hyphen at the end.
    return substr($matches[0], 0, -1);
  }
  else {

    // Passed string did not include a proper weight; set a warning.
    _lineage_format_warning();
    return FALSE;
  }
}