function FilterPluginBase::arrayFilterZero

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::arrayFilterZero()
  2. 8.9.x core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::arrayFilterZero()
  3. 10 core/modules/views/src/Plugin/views/filter/FilterPluginBase.php \Drupal\views\Plugin\views\filter\FilterPluginBase::arrayFilterZero()

Filter by no empty values, though allow the use of (string) "0".

Parameters

string $var: The variable to evaluate.

Return value

bool TRUE if the value is equal to an empty string, FALSE otherwise.

File

core/modules/views/src/Plugin/views/filter/FilterPluginBase.php, line 1678

Class

FilterPluginBase
Base class for Views filters handler plugins.

Namespace

Drupal\views\Plugin\views\filter

Code

protected static function arrayFilterZero($var) {
    if (is_int($var)) {
        return $var != 0;
    }
    return trim($var) != '';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.