function lineage_get_weight in Taxonomy Lineage 7
Same name and namespace in other branches
- 6 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 the term_string, or false on failure.
File
- ./
lineage.module, line 303 - lineage.module Module code for taxonomy term hierarchy lineage.
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;
}
}