Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

filter_match()

Description

In the given filter string, does name/value match?
Returns:
0 = no match for name
1 = matched name but value was not present
2 = matched name and value was correct

Parameters

ColumnTypeDefaultDescription
$filter string Sring to for which filtering is to be applied
$name string Name to match
$value string Value to match

Return

int

Location

include/resource_functions.php lines 5674 to 5704

Definition

 
function filter_match($filter,$name,$value)
    {
    
$s=explode(";",$filter);
    foreach (
$s as $condition)
        {
        
$s=explode("=",$condition);
        
# Support for "NOT" matching. Return results only where the specified value or values are NOT set.
        
$checkname=$s[0];$filter_not=false;
        if (
substr($checkname,-1)=="!")
            {
            
$filter_not=true;
            
$checkname=substr($checkname,0,-1);# Strip off the exclamation mark.
            
}
        if (
$checkname==$name)
            {
            
$checkvalues=$s[1];

            
$s=explode("|",strtoupper($checkvalues));
            
$v=trim_array(explode(",",strtoupper($value??"")));
            foreach (
$s as $checkvalue)
                {
                if (
in_array($checkvalue,$v))
                    {
                    return 
$filter_not 2;
                    }
                }
            return 
$filter_not 1;
            }
        }
    return 
0;
    }

This article was last updated 19th March 2024 05:35 Europe/London time based on the source file dated 11th March 2024 14:25 Europe/London time.